Created
November 19, 2012 17:16
-
-
Save jimbojsb/4112010 to your computer and use it in GitHub Desktop.
args problem
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 | |
passthru('clear'); | |
$args = array(1,2,3,4,5); | |
class Foo | |
{ | |
public function bar($args) | |
{ | |
$args[] = 6; | |
echo '$args inside Foo->bar(): ' . "\n" . print_r($args, 1); | |
} | |
} | |
foreach($args as &$arg) { | |
if(is_object($arg)) { | |
// | |
} | |
} | |
echo '$args in global scope: ' . "\n" . print_r($args, 1) . "\n\n"; | |
$a = new Foo(); | |
$class = new ReflectionClass($a); | |
$method = $class->getMethod('bar'); | |
$result = $method->invokeArgs($a, array($args)); | |
echo '$args in global scope: ' . "\n" . print_r($args, 1) . "\n\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment