php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47320 $php_errormsg out of scope in functions
Submitted: 2009-02-05 23:12 UTC Modified: 2009-02-09 09:21 UTC
From: danielc at analysisandsolutions dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.0beta1 OS: *
Private report: No CVE-ID: None
 [2009-02-05 23:12 UTC] 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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-05 23:45 UTC] jani@php.net
Compared to what version?
 [2009-02-05 23:48 UTC] danielc at analysisandsolutions dot com
Compared to 5.2.6.
 [2009-02-05 23:55 UTC] mattwil@php.net
Caused, and missed, by Dmitry's lazy EG(active_symbol_table) initialization? http://news.php.net/php.cvs/49754
 [2009-02-06 22:34 UTC] johannes@php.net
Dmitry, can you take a look, please?
 [2009-02-09 09:21 UTC] dmitry@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC