Here's what I'd change in PHP if could:
1. Make it mandatory to declare a variable before initialising it kinda like Javascript:
This will prevent a lot of mistakes that could be hard to debug or lead to security holes.Code:var $newvar = 1;
2. Remove extract(), compact(), register_globals, the global keyword (maybe keep $_GLOBALS).
3. Think about object literals. Ideally they would create new objects of class stdClass or something.
The actual syntax I used is debatable; to emulate Javascript you could use {x:4, y:2} but the above seemed more consistent with other parts of PHP such as array().Code:$myobj = object(x => 4, y => 2);
PS. I don't like many of the previous suggestions. If there's already a way to do it in PHP then why not leave it as is, for example $this->something is perfectly fine and it's not as if #something saves any actual lines of code (in this instance, I'd say it makes it less intuitive as well).



[mmj] My magic jigsaw









Bookmarks