What is your most hated PHP's syntax/feature?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
julian_lp
Forum Contributor
Posts: 121
Joined: Sun Jul 09, 2006 1:00 am
Location: la plata - argentina

What is your most hated PHP's syntax/feature?

Post 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 :roll:
Last edited by julian_lp on Mon Nov 13, 2006 1:13 am, edited 2 times in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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()).
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

As above. Not much bugs me about the syntax, only the inconsistencies within the standard library.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

  • Code: Select all

    <?php echo abcde ?>
    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
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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...
Post Reply