PHP 4.0 Bug #4120: Method calls fail using -e command line option

From: Date: Wed, 12 Apr 2000 22:31:14 +0000
Subject: PHP 4.0 Bug #4120: Method calls fail using -e command line option
Groups: php.dev 
Request: Send a blank email to php-dev+get-17849@lists.php.net to get a copy of this message
From: Mark_Dixon@teamstudio.com Operating system: NT PHP version: 4.0 Release Candidate 1 PHP Bug Type: Scripting Engine problem Bug description: Method calls fail using -e command line option Sample script, saved as class.php <?php class MyClass { function myFunc( $arg ){ echo $arg; } } $obj = new MyClass; $obj -> myFunc( "Hello, world" ); ?> Running 'php class.php' works, 'php -e class.php' fails with 'Call to undefined function: ()' The problem is the additional ZEND_EXT_FCALL_BEGIN op which gets in the way in do_begin_dynamic_function_call. I'd humbly suggest modifying do_extended_fcall_begin to something like void do_extended_fcall_begin(CLS_D) { zend_op *opline; int last_op_number = get_next_op_number(CG(active_op_array))-1; if (!CG(extended_info)) { return; } opline = get_next_op(CG(active_op_array) CLS_CC); // If the last instruction is ZEND_FETCH_OBJ_R then it's about to be converted to a // ZEND_INIT_FCALL_BY_NAME in do_begin_dynamic_function_call. So we need to slide the FETCH_OBJ_R // up one and insert the EXT_FCALL_BEGIN before it. if (last_op_number>=0 && CG(active_op_array)->opcodes[last_op_number].opcode == ZEND_FETCH_OBJ_R) { memcpy( opline, &CG(active_op_array)->opcodes[last_op_number], sizeof( zend_op ) ); opline = &CG(active_op_array)->opcodes[ last_op_number ]; } opline->opcode = ZEND_EXT_FCALL_BEGIN; SET_UNUSED(opline->op1); SET_UNUSED(opline->op2); } Regards Mark

« previous php.dev (#17849) next »