ID: 17246 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Solaris 8 PHP Version: 4.2.0 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php The sample code works, if it does not you may need to enable 'allow_call_time_pass_reference' option. Previous Comments: ------------------------------------------------------------------------ [2002-05-15 08:27:27] [EMAIL PROTECTED] Sorry, output is wrong. following right output: case 1: $a = 1 $b = 2 case 2: $a = 1 $b = 2 case 3: $a = foo $b = bar case 4: $a = 1st $b = 2nd case 5: $a = 1 $b = 2 case 6: $a = 1st $b = 2nd Regards, KUBO Atsuhiro ------------------------------------------------------------------------ [2002-05-15 08:13:06] [EMAIL PROTECTED] Hi, I falied in passing by reference using call_user_function(). In case 2 and 5, I expect that $a and $b are overwritten by MyMethod or MyFunction. However, they were not overwritten. Is this right doing? Or is my understanding wrong? Regards, KUBO Atsuhiro test code: <?php class MyClass { function MyMethod(&$arg1, &$arg2) { $arg1 = 'foo'; $arg2 = 'bar'; } } print "case 1:\n"; $a = 1; $b = 2; print '$a = ' . $a . "\n"; print '$b = ' . $b . "\n"; print "case 2:\n"; $a = 1; $b = 2; $obj = new MyClass; call_user_func(array(&$obj, 'MyMethod'), $a, $b); print '$a = ' . $a . "\n"; print '$b = ' . $b . "\n"; print "case 3:\n"; $a = 1; $b = 2; call_user_func(array(&$obj, 'MyMethod'), &$a, &$b); print '$a = ' . $a . "\n"; print '$b = ' . $b . "\n"; print "case 4:\n"; $a = 1; $b = 2; MyFunction($a, $b); print '$a = ' . $a . "\n"; print '$b = ' . $b . "\n"; print "case 5:\n"; $a = 1; $b = 2; call_user_func('MyFunction', $a, $b); print '$a = ' . $a . "\n"; print '$b = ' . $b . "\n"; print "case 6:\n"; $a = 1; $b = 2; call_user_func('MyFunction', &$a, &$b); print '$a = ' . $a . "\n"; print '$b = ' . $b . "\n"; exit(); function MyFunction(&$arg1, &$arg2) { $arg1 = '1st'; $arg2 = '2nd'; } ?> output: $a = 1 $b = 2 case 2: $a = 1 $b = 2 case 3: $a = foo $b = bar case 4: $a = hoge $b = huge case 5: $a = 1 $b = 2 case 6: $a = hoge $b = huge ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17246&edit=1
