Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Here's a pitfall I know from briefly trying to improve PHP, and having developed in it:

The syntax definition is used for some types of basic type-checking.

I'm completely serious.

Because of this, if you try to do a combination of property/array/etc. accesses that the grammar designers didn't envision, you'll get a very cryptic error. For example, this (which runs an anonymous function dereferenced from an array dereferencing from a static member of a class):

  self::$views[$path]();
Doesn't work. It assumes that the result of self::$views[$path] is a string, and then complains there is no function with that name. (Yes, you can execute strings with names of functions, as if they were that function...) But this:

  $x = self::$views[$path];
  $x();
Does work.

Please, don't use PHP. It's horrible.



Because all other languages are without problems.


PHP has more than its fair share.


Instantly invoking Godwin's law; knowing about the Nazis causes a moral shift towards making sure some horrible things don't happen again.

The same applies to PHP. please do use it for a bit, learn about the crimes and don't repeat them :)


[deleted]


  Parse error: syntax error, unexpected '[' in D:\Projects\2012\45blocks\45blocks\src\framework.php on line 18
No it doesn't.


I'm sorry I deleted my post, didn't see your reply in time.

  $this->views[$path]();
should not throw an error. What version are you using?


PHP 5.4. Let's try that code:

  Fatal error: Using $this when not in object context in D:\Projects\2012\45blocks\45blocks\src\framework.php on line 19
It's a static class member.


You're right, I didn't get that it doesn't work in a static context. I stand corrected, that definitely sucks.


> Please, don't use PHP. It's horrible.

I wish I could upvote this comment a dozen times, for a combination of candor and useful fact.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: