Skip to content

Instantly share code, notes, and snippets.

@markkelnar
Created September 14, 2012 18:11
Show Gist options
  • Save markkelnar/3723638 to your computer and use it in GitHub Desktop.
Save markkelnar/3723638 to your computer and use it in GitHub Desktop.
PHP variable variables
<?php
# Reference http://us.php.net/language.variables.variable
class foo { static function hello() { print __LINE__." ".get_class()." world\n"; } }
class bar { function hello() { print __LINE__." ".get_class()." world\n"; } }
function hello() { print __LINE__." world\n"; }
call_user_func('hello');
call_user_func( array('foo','hello') );
$z = new bar();
call_user_func( array($z,'hello') );
$a = 'hello';
call_user_func($a);
$hello = 'world';
print __LINE__." ".$$a."\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment