Created
April 4, 2013 16:07
-
-
Save wakhub/5311721 to your computer and use it in GitHub Desktop.
PHP5.4 New Syntax Test
This file contains 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 | |
// http://php.net/manual/en/migration54.new-features.php | |
// http://php.net/manual/en/closure.bindto.php | |
class Sample { | |
public static function getArray() { | |
return [0b100, 0b101, 0b111]; | |
} | |
public $obj = []; | |
public function setObj($obj) { | |
$this->obj = $obj; | |
return $this; | |
} | |
public function getDumper() { | |
return function() { | |
var_dump($this->obj); | |
}; | |
} | |
} | |
var_dump( | |
Sample::{ 'get' . 'Array' }()[2] | |
); | |
$dumper = (new Sample)->{ implode('', ['set', 'Obj']) }([ | |
'foo' => 'FOO', | |
'bar' => 'BAR', | |
'baz' => 'BAZ' | |
]) | |
->{ 'getDumper' }(); | |
$dumper(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment