Skip to content

Instantly share code, notes, and snippets.

@jimbojsb
Created November 19, 2012 17:16
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 jimbojsb/4112010 to your computer and use it in GitHub Desktop.
Save jimbojsb/4112010 to your computer and use it in GitHub Desktop.
args problem
<?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