• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

<RANT> I Hate PHP :(

Armitage

Banned
What a damn kludge ... you can never just assume something is there and/or works right.

Examples ... strftime exists, but not strptime WTF?

printf is completely hosed ... I have a formatted output statement that works fine in C and Python

"%03i%08.4f"

First problem ... PHP printf doesn't have an 'i' type specifier, have to use 'u'.

Now for y=3 and x = 1.23456, the result of this statement should be:

printf("%03u%08.4f", $y, $x);

003001.2346

instead I get

00300000001.2346

it pads the field before the decimal to 8 places, instead of the entire field to 8 places! 🙁

So, I try to work around it. I know the value of x will always be less then 1000, so I can add some if statements and pad it manually, like this:

if($x < 10)
printf("%03u00%6.4f", $y, $x);

Here's the result:

00300 1.2346

Who the fvck told it to put a space in there???
It seems every time I try something in PHP, I find some stupid cruft like this.

arghh
Fvck it, it's supposed to be my day off anyway, I'm going home.
 
Yes, php sucks. It was designed as a quick hack for making interactive web pages, spiraled out of control, and was never properly designed to handle the stuff it is used for, and therefore sucks ass. It's very appropriate for small pages with little bits of interactivity or dynamic content, but for anything complex it is a P I T A. Anyone who thinks it's not a pita for big stuff is either crazy or just hasn't experienced anything better. Ugh.
 
The same people pushing PHP as a serious programming language are the ones pushing notepad as a serious text editor.
 
Hah, yeah, that's a very good analogy. 🙂

edit: BTW, namespaces are NOT going to be in php5, they took them out at the last moment. 🙁
 
This stuff just pisses me off ... it's the kind of error I expect to find in beta code that hasn't reached v1.0 yet, not something up to 4.3 and widely used.

So what's a better free or cheap alternative for use with apache/mysql on Linux?
I'm not a serious web developer, but I've been roped into doing some database-backed web development.

Please don't say Perl!
 
Python 😀

You already know it!

I used it a little through cgi, the cgi, cgitb, and urllib modules are helpful. Supposedly mod_python is a lot better than python through cgi, but back when I first tried it it seemed like more trouble than it was worth (considering I was just playing around).
 
Most important stuff in huge projects is how good you prepare for programing (UML), jumping in and starting coding right away will end like a big mess
whatever language you're gona use.
Personally I find php and perl very good solutions, haven't tried python thought.
 
mod_perl is fast as hell and perl rocks for string parsing and has modules for anything you can think of.

screw that...use SQL Server/IIS/ASP

And that ties you to a single vendor for everything, sweet.
 
Originally posted by: BingBongWongFooey
Python 😀

You already know it!

I used it a little through cgi, the cgi, cgitb, and urllib modules are helpful. Supposedly mod_python is a lot better than python through cgi, but back when I first tried it it seemed like more trouble than it was worth (considering I was just playing around).

I looked at mod_python once, and it looked like a complete PITA ... but maybe I'll have another look.
 
Originally posted by: Nothinman
mod_perl is fast as hell and perl rocks for string parsing and has modules for anything you can think of.

Yea, well there's some bad blood between me & perl, and I just don't have time to fight the learning curve on this project.

[/quote]
screw that...use SQL Server/IIS/ASP

And that ties you to a single vendor for everything, sweet.[/quote]

Not an option
rolleye.gif

 
Uhhh...maybe you should actually read PHP manual entries on printf and sprintf. They clearly state the problem with your code.

"%03u%08.4f" will print a 3 digit and an 8 digit number, followed by 4 decimals. What you want is "%03u%03.4f"

Your other code won't work because as it clearly states in the manual, "The default is to pad with spaces."

PHP is not ASP/Perl/Python/VB/Java/C++, so you shouldn't expect every function from every other language to be present, nor should you expect it to work the same way.
 
Well, it's their choice of course, but IMO, if you are going to adapt common conventions and functionality of other languages such as printf & format strings, you shouldn't introduce subtle (and not so subtle) differences in the behavior. I suspect that most people using PHP are not learning it as a first language, and many of them come from a C background. So by introducing these significant differences for no discernable reason, you 1. Make learning the language more difficult, particularly for experienced programmers. 2. Increase errors due to the unexpected behavior.

Now for your specific assertions, heres a chunck of the relevant manual section:

Each conversion specification consists of a percent sign (%), followed by one or more of these elements, in order:

1. An optional padding specifier that says what character will be used for padding the results to the right string size. This may be a space character or a 0 (zero character). The default is to pad with spaces. An alternate padding character can be specified by prefixing it with a single quote ('). See the examples below.

2. An optional alignment specifier that says if the result should be left-justified or right-justified. The default is right-justified; a - character here will make it left-justified.

3. An optional number, a width specifier that says how many characters (minimum) this conversion should result in.


This guidance is consistent with the behavior of C or Python. It refers to the '8' in %08.4f, and idicates that the total field should have a minimum length of 8 It says nothing about this number representing just the places left of the decimal place, although that is what it produces.

4. An optional precision specifier that says how many decimal digits should be displayed for floating-point numbers. This option has no effect for other types than float. (Another function useful for formatting numbers is number_format().)

Again, no indication that this precision specifier can expand the total width of the field as set by the width specifier.

5. A type specifier that says what type the argument data should be treated as. Possible types: ....


Finally, in my second bit of code, I didn't ask for any padding ... I asked for a total field width of 6.
 
Originally posted by: Nothinman
mod_perl is fast as hell and perl rocks for string parsing and has modules for anything you can think of.

screw that...use SQL Server/IIS/ASP

And that ties you to a single vendor for everything, sweet.

you forgot to add that it is a pain in the ass to debug...
 
Originally posted by: adrianwalters
Originally posted by: Nothinman mod_perl is fast as hell and perl rocks for string parsing and has modules for anything you can think of.
screw that...use SQL Server/IIS/ASP
And that ties you to a single vendor for everything, sweet.
you forgot to add that it is a pain in the ass to debug...

How so? I develope ASP.NET pages in Visual Studio .NET 2003 all the time. I have no problem debugging.
 
Originally posted by: HJB417
vs.net is the best c++ IDE i've ever seen & used

Me too. I have not seen or used anything that comes even close to the feature list. I can use a single IDE to develop applications in C++, C#, Java, ASP.NET, etc...
 
Originally posted by: KraziKid
Originally posted by: HJB417
vs.net is the best c++ IDE i've ever seen & used

Me too. I have not seen or used anything that comes even close to the feature list. I can use a single IDE to develop applications in C++, C#, Java, ASP.NET, etc...

well, about the java, I hate that it's only limited to 1.1.4. When I was taking a course using java, I started projects in j# and then imported the code to jbuilder. I really love the debugger though.
 
Originally posted by: KraziKid
Originally posted by: adrianwalters
Originally posted by: Nothinman mod_perl is fast as hell and perl rocks for string parsing and has modules for anything you can think of.
screw that...use SQL Server/IIS/ASP
And that ties you to a single vendor for everything, sweet.
you forgot to add that it is a pain in the ass to debug...

How so? I develope ASP.NET pages in Visual Studio .NET 2003 all the time. I have no problem debugging.

I was referring to perl not ASP.NET
 
Back
Top