Page 1 of 1
What is your most hated PHP's syntax/feature?
Posted: Sun Nov 12, 2006 11:36 pm
by julian_lp
Of course we all love PHP. But even in our most beloved things there are always small parts which we would change...
What about PHP?
My first 3 hated items:
1)
Code: Select all
$object->Method();
instead of:
$object.Method();
(Why 2 characters that far away on keyboard each other? I'd love "." instead, and % for concatenation for instance)
2) case sensitivity (come on! Hello and hEllo are the same thing !!! )
3) $ (I'd preffer just declare the variables)
With regard point number 3, I see no reason to do, inside a class declaration:
var $whatever;
It's like saying var twice...
Note: I know that 1 comes from Perl and 2 from C

Posted: Mon Nov 13, 2006 12:38 am
by RobertGonzalez
The two things that drive me nuts are 1) the inconsistent formatting of functions parameters (some go $needle, $haystack and some do it the other way) and 2) inconsistent function naming (like
print_r() and
sprintf()).
Posted: Mon Nov 13, 2006 3:42 am
by Jenk
As above. Not much bugs me about the syntax, only the inconsistencies within the standard library.
Posted: Mon Nov 13, 2006 4:12 am
by Chris Corbyn
Nothing really. I mean, some stuff bugs me about the wayt it's parsed but not the syntax itself.
I'm happy using $obj->item and afaik it's not only used in PHP. The same syntax is used in C but for different meanings so I can see how that may be confusing. % is modulus in most languages so using that as a string operator wouldn't feel right.
Things that bug me about the way it's parsed:
__toString() only works when type casting (fixed in 5.2.0)
The new keyword needs to return to a variable before the object can be used, i.e.:
Code: Select all
new MyClass()->method(); //doesn't work
(new MyClass())->method(); //doesn't work
MyClass::instance()->method(); //DOES work
I'd like to see stricter types added but only as an option to developers, without actually forcing people to implement it. As in:
Code: Select all
public function float getBodyMassIndex(string $gender, float $weight, float $height)
{
//
}
And I'd like to see namespacing. I could clean up so many hideously long class names with some namespacing/packaging support.
Posted: Mon Nov 13, 2006 6:22 am
by Maugrim_The_Reaper
Some of the above (except case sensitivity does make sense...

).
In the past few weeks, my main annoyance has been how SimpleXML handles invalid XML characters and entities when using SimpleXMLElement::addChild() .
- it can't handle CDATA
- it reverses attempts to entitise quotes (single and double)
- other weird entity behaviour
Sometimes I was tempted to just use DOM. addChild() is anything but simple...
Posted: Mon Nov 13, 2006 6:50 am
by volka
- Notice: Use of undefined constant abcde - assumed 'abcde'
silent "error correction" gives me headache, grrr - php never provided and enforced frameworks/libraries like e.g. java did, starting with the basic collection framework. And this imho favours the rank growth of many non-consistent libraries/frameworks - and you have to know them all because everyone is using this or that or "something I found on the web", grrrr
Posted: Mon Nov 13, 2006 10:13 am
by Maugrim_The_Reaper
The structured item is always arguable - would PHP be so popular if it was highly structured?
For myself, I first started in PHP because it was delightfully easy to create quick hacked together functions. It's very easy to learn as a result. Of course, the downside is that not everyone goes any further and learns to do things better (i.e. especially security). PHP's reputation as a language is tarnished as a result.
I wonder if folk is ever stop comparing PHP to Rails?

PHP ain't a framework...