ID: 21604
Comment by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Zend Engine 2 problem
Operating System: Windows 2000 Server
PHP Version: 4.2.3
New Comment:
This is a "feature", not a bug. I can see good uses for this, my
DataObject class uses this feature for dynamically adding instance
variables from database records.
Previous Comments:
[2003-01-12 22:46:08] [EMAIL PROTECTED]
If you run the following script and check the output, you will see the
that variable JUNK has been dynamically defined in the class X_Row() by
using the statement:
$user->query_row->JUNK = "stuff";
This behaviour certainly wasn't what I would expect.
---
query_row = new X_Row();
return;
}
}
class X_Row
{
var $USERNAME;
var $PASSWORD;
var $CHECKING;
function X_Row() {
$this->USERNAME = NULL;
$this->PASSWORD = NULL;
$this->CHECKING = NULL;
return;
} //end function X_Row
} //X_Row
$user = new X();
//$user->query_row is of class X_Row
//Therefore, the next statement should be valid,
//USERNAME has been declared in X_Row
$user->query_row->USERNAME = 'mtl';
//But the next statement shouldn't be
//because the variable JUNK has not
//been declared in the class
$user->query_row->JUNK = 'stuff';
$classname = get_class($user->query_row);
$classvars = get_class_vars($classname);
$query_row_class_vars = array_keys($classvars);
echo "classname:{$classname}";
echo "classvars:";
var_dump($classvars);
echo "query_row_class_vars";
var_dump($query_row_class_vars);
echo "HOW IS THIS POSSIBLE? SEE BELOW!";
echo "user->query_row:";
var_dump($user->query_row);
?>
--
Edit this bug report at http://bugs.php.net/?id=21604&edit=1