|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22367 undefined variable has a value
Submitted: 2003-02-21 17:31 UTC Modified: 2003-08-26 23:24 UTC
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:3 (75.0%)
From: stanislav dot chachkov at epfl dot ch Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.0 OS: Solaris8
Private report: No CVE-ID: None
 [2003-02-21 17:31 UTC] stanislav dot chachkov at epfl dot ch
In a method we have that ($a is undefined,
but this also works if you substitute $a by any other name):

function getColumnValue($col_name){
  var_dump($a); echo "a=$a  <br>";

This method is called a number of times and the output is like this:

NULL a=Etape_Editor_IDEtape_Editor_ID''

Actually "EtapeEditor_ID" was the parameter of PREVIOUS call to one of methods of this class. 
I can not reproduce this problem with a short script, it seems that it appears only when the number of classes, objects and calls is large, otherwise it works fine.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-23 13:16 UTC] stanislav dot chachkov at epfl dot ch
This is the test case:

class A{
  var $fields;
  function getID(){
    return $this->getColumnValue($this->getPK());
  function getColumnValue($col_name){
    return $this->fields[$col_name];
  function save(){
    echo "Dump of z: ";
    echo "<br>z=";
    echo $z;
    echo "<br>";
      echo "undefined is now defined<br>";
      echo "undefined is undefined<br>";
    echo "s1=$s1, s2=$s2";

class B extends A{
  function getPK(){
    return "ID";
  function &getColumnValue($col_name){
    return parent::getColumnValue($col_name);

$b=new B();


The output that we have is:

Dump of z: NULL
undefined is now defined
s1=NO, s2=NO
 [2003-02-24 15:11 UTC] stanislav dot chachkov at epfl dot ch
We found a workaround: getColumnValue functions should both return a reference or both return a value. 
Actually it is also possible to return a reference from class A and value from sub class B, but the inverse breaks the stack.
 [2003-03-24 04:31 UTC]
Related to bug #22836
 [2003-08-26 23:24 UTC]
This is fixed in PHP 5, won't be fixed in PHP 4.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 00:01:29 2024 UTC