Skip to content

Instantly share code, notes, and snippets.

@wakhub
Created April 4, 2013 16:07
Show Gist options
  • Save wakhub/5311721 to your computer and use it in GitHub Desktop.
Save wakhub/5311721 to your computer and use it in GitHub Desktop.
PHP5.4 New Syntax Test
<?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