#47320 [Fbk->Opn]: $php_errormsg out of scope in functions

From: Date: Thu, 05 Feb 2009 23:48:07 +0000
Subject: #47320 [Fbk->Opn]: $php_errormsg out of scope in functions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133551@lists.php.net to get a copy of this message
ID: 47320 User updated by: danielc at analysisandsolutions dot com Reported By: danielc at analysisandsolutions dot com -Status: Feedback +Status: Open Bug Type: Scripting Engine problem Operating System: * PHP Version: 5.3.0beta1 New Comment: Compared to 5.2.6. Previous Comments: ------------------------------------------------------------------------ [2009-02-05 23:45:07] jani@php.net Compared to what version? ------------------------------------------------------------------------ [2009-02-05 23:12:59] danielc at analysisandsolutions dot com Description: ------------ The scope of $php_errormsg has changed in 5.3. It is no longer available inside functions. Perhaps this is intentional, perhaps not. If it is intentional, I encourage the decision be changed to improve compatibility between versions. If it won't be changed, we need to update the 5.3 upgrade guide at http://wiki.php.net/doc/scratchpad/upgrade/53. Reproduce code: --------------- if (!@substr('no 2nd parameter')) { echo '$php_errormsg in global: ' . $php_errormsg . "\n"; } function foo() { if (!@substr('no 2nd parameter')) { echo '$php_errormsg in function: ' . $php_errormsg . "\n"; echo '$GLOBALS[php_errormsg] in function: ' . $GLOBALS['php_errormsg'] . "\n"; } } foo(); Expected result: ---------------- $php_errormsg in global: substr() expects at least 2 parameters, 1 given $php_errormsg in function: substr() expects at least 2 parameters, 1 given $GLOBALS[php_errormsg] in function: substr() expects at least 2 parameters, 1 given Actual result: -------------- $php_errormsg in global: substr() expects at least 2 parameters, 1 given Notice: Undefined variable: php_errormsg in D:\webroot\ideasphp\Atest.html on line 10 $php_errormsg in function: $GLOBALS[php_errormsg] in function: substr() expects at least 2 parameters, 1 given ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47320&edit=1

« previous php.bugs (#133551) next »