Archive for the ‘PHP’ Category

Next PHP uselessness of the day

Tuesday, December 11th, 2007

There is the option “php -l” which checks the validity of a source file. Obviously it doesn’t do a wonderful job as it doesn’t detect misspelt variable or method names; but I suppose it’s better than nothing.

So I apply this recursively to all the files under a certain directory. For reasons I won’t go into here there are Postscript fonts checked into the source directory. To this files, “php -l” outputs:

No syntax errors detected in ./pdflib/fonts/php_Times-Italic.afm

I assert “php -l” is not very useful.

Unbelievable PHP limitation of the day

Monday, December 10th, 2007

If one defines a class with the member variable:

protected static $bytes = 12582912;

then that’s fine. However if one defines it as:

protected static $bytes  = 12*1024*1024; // 12 MB

then that gives a compile error:

Parse error: syntax error, unexpected '*', expecting ',' or ';'

I know of no other language that I’ve ever programmed (i.e. including BASIC, and C) where you can write a value, but you can’t write an expression.

How broken is that!

Putting spaces around the *, or adding brackets around the whole expression, does not help.

(PHP 5.2.0)