#21669 [NEW]: "$obj = new $this->var;" doesn't work

2003-01-15 Thread slowbyte
From: [EMAIL PROTECTED]
Operating system: Debian Linux 3.0r0
PHP version:  5CVS-2003-01-15 (dev)
PHP Bug Type: Zend Engine 2 problem
Bug description:  "$obj = new $this->var;" doesn't work

The following snippet is a parse error in PHP5-ZE2 (used to work on earlier
versions). This feature is also used in Smarty templates.

name; /* Parse error */
return $obj;
}
}
$factory = new Factory;
$test = $factory->create();
$test->say_hello();
?>

-- 
Edit bug report at http://bugs.php.net/?id=21669&edit=1
-- 
Try a CVS snapshot: http://bugs.php.net/fix.php?id=21669&r=trysnapshot
Fixed in CVS:   http://bugs.php.net/fix.php?id=21669&r=fixedcvs
Fixed in release:   http://bugs.php.net/fix.php?id=21669&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=21669&r=needtrace
Try newer version:  http://bugs.php.net/fix.php?id=21669&r=oldversion
Not developer issue:http://bugs.php.net/fix.php?id=21669&r=support
Expected behavior:  http://bugs.php.net/fix.php?id=21669&r=notwrong
Not enough info:http://bugs.php.net/fix.php?id=21669&r=notenoughinfo
Submitted twice:http://bugs.php.net/fix.php?id=21669&r=submittedtwice
register_globals:   http://bugs.php.net/fix.php?id=21669&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21669&r=php3
Daylight Savings:   http://bugs.php.net/fix.php?id=21669&r=dst
IIS Stability:  http://bugs.php.net/fix.php?id=21669&r=isapi
Install GNU Sed:http://bugs.php.net/fix.php?id=21669&r=gnused




#21604 [Com]: variables can be dynamically added to a class, without it being defined.

2003-01-15 Thread slowbyte
 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