Created
May 26, 2013 05:35
-
-
Save bilalq/5651814 to your computer and use it in GitHub Desktop.
PHP 5.4 advantages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Array Literal support | |
$my_array = [ | |
'you can use', | |
'[]', | |
'now' | |
]; | |
// This used to be a parse error in PHP 5.3. | |
$some_var = my_func()[0]; | |
/** | |
* You used to have to do this: | |
* $some_var = my_func(); | |
* $some_var = my_func[0]; | |
*/ | |
// References to $this in closures | |
class Foo { | |
private $value = 0; | |
public function getTheValueGetter() { | |
return function() { return $this->value; }; | |
} | |
} | |
// You also get better performance. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Array Literal support: No wonder it ran fine in my Ironman (PHP 5.4), and yet when I git pull at Jarvis (PHP 5.3), it gave me an error.