Skip to content

Instantly share code, notes, and snippets.

@bilalq
Created May 26, 2013 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bilalq/5651814 to your computer and use it in GitHub Desktop.
Save bilalq/5651814 to your computer and use it in GitHub Desktop.
PHP 5.4 advantages
<?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.
@kenliau
Copy link

kenliau commented May 26, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment