|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-01-15 11:50 UTC] slowbyte at hot dot ee
[2003-01-15 20:11 UTC] bmichael at goldparrot dot com
[2003-01-25 08:51 UTC] hholzgra@php.net
[2003-01-25 10:59 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 18:00:02 2025 UTC |
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. ----------------------- <?php class X { var $query_row; function X() { $this->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}<br>"; echo "classvars:<br>"; var_dump($classvars); echo "<br>query_row_class_vars<br>"; var_dump($query_row_class_vars); echo "<br><br>HOW IS THIS POSSIBLE? SEE BELOW!!!!!!!!!"; echo "<br>user->query_row:<br>"; var_dump($user->query_row); ?>