#22288 [NEW]: Local vars and function parameters not accessible!
| From: | andre dot goncalves at martelozero dot com | Date: | Wed, 19 Feb 2003 05:26:04 +0000 |
| Subject: | #22288 [NEW]: Local vars and function parameters not accessible! | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-33500@lists.php.net to get a copy of this message | ||
From: andre dot goncalves at martelozero dot com
Operating system: Linux
PHP version: 4.3.1
PHP Bug Type: Variables related
Bug description: Local vars and function parameters not accessible!
Hi! this is really a spooky situation!
A. problem with a class only happening in one site (other implementations
use same class and always worked fine).
B. It only happens the first time I hit the site.
C. press F5, or re-enter address, and the problem is gone.
D. restarting browser, causes the problem again.
E. problem is:
The 2nd time I call a method on a certain object,
neither the method parameters, neither the global vars are
acessible, only the pre-declared class members are there.
Remember, i have made a call to this method in the same script
exexcutation, some 20 lines before.
F. Even more spooky, some vars tend to echo values (wrong
values) but var_dump shows NULL for the same var,
right from the next line of code!!!
G. Check below example:
output 1, 3 and 4 show vardump of function parameters NULL
ouput 2 shows that local var $_query (the function's parameter $_query)
receives the return value of the previous function foofunction() call
output 3 shows that variable is in fact NULL
output 5 shows that local var is not accessible
output 6 shows that global var is accessible
output 7 and 8 shows class members ok
output 9 and 10 shows assigning local vars impossible!!!!
H. Don't belive me? TEST IT:
http://66.220.28.17/zero/index.php
Looks like assignment of variables is totally messed up (currupt?)
The script is like dead: I also tried unseting the global
instance of $mydbclass and recreating it, but I get NULL
if I vardump the new instance!!!
Please help me on this one!
//:: CODE EXTRACT FOLLOWS
//:: test function
function foofunction($_bla) {
return "YOUR BLAH: ".$_bla;
}
$fooglobal= "fooglobal";
// function call
$mydbclass->query("select id from user");
//class definition
class mydbclass {
var $version = 1.0
function mydbclass() {
$this->connect(); }
// more class methods ...
function query($_query = "foo", $_fooparam = "bar") {
global $fooglobal;
global $queryix;
$queryix++;
$foolocal = "foolocal";
$this->foonewmember = "foonewmember";
echo "($queryix) _query=";
var_dump($_query);echo BR;
//:: 1 outputs: (2) _query=NULL
if (!($this->tmp = mysql_query($_query))) { ;
$this->tmp2 = $this->bla("select id from zero_user");
echo "_query echo=";
echo($_query);
//::2 outputs: _query echo=YOUR BLAH: bla bla
echo "_query dump=";
var_dump($_query);
//::3 ouputs: _query dump=NULL
echo "_fooparam=";
var_dump($_fooparam);
//::4 ouputs: fooparam=NULL
echo "globalfoo=";
var_dump($fooglobal);
//::5 ouputs: fooglobal=fooglobal
echo "foolocal=";
var_dump($foolocal);
//::6 ouputs: foolocal=NULL
echo "foonewmember=";
var_dump($this->foonewmember);
//::7 ouputs: foonewmember=string(12) "foonewmember"
echo "foooldmember=";
var_dump($this->foooldmember);
//::8 ouputs: foooldmember=string(9) "foooldmember"
echo "result1=";
var_dump($this->result1);
//::9 ouputs: result1=bool(false)
echo "result2=";
var_dump($this->result2);
//::10 ouputs: result2=NULL
}
// more class methods ...
} // end of class
__________________
Thanks,
André Gonçalves
--
Edit bug report at http://bugs.php.net/?id=22288&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=22288&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=22288&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=22288&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=22288&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=22288&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=22288&r=support
Expected behavior: http://bugs.php.net/fix.php?id=22288&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=22288&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=22288&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=22288&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22288&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=22288&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=22288&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=22288&r=gnused