#29767 [Opn]: Weird behaviour of __set($name, $value);

From: Date: Fri, 20 Aug 2004 02:16:42 +0000
Subject: #29767 [Opn]: Weird behaviour of __set($name, $value);
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-64985@lists.php.net to get a copy of this message
ID: 29767 User updated by: morten at nilsen dot com Reported By: morten at nilsen dot com Status: Open Bug Type: Zend Engine 2 problem Operating System: Linux PHP Version: 5.0.1 New Comment: (obvious) workaround is to change: if($name[0] != '&') $name = '&'.$name.';'; into: $entity = "&$name;"; Previous Comments: ------------------------------------------------------------------------ [2004-08-20 03:55:51] morten at nilsen dot com Description: ------------ The attached script behaves ilogically Reproduce code: --------------- <?php class template { function __set($name, $value) { echo "Set $name to $value<br>"; if($name[0] != '&') $name = '&'.$name.';'; } } function fetchlist($name) { global $template; echo '$template->what = '.$name.'<br>'; $template->what = $name; } $template = new template(); fetchlist('user'); fetchlist('group'); ?> Expected result: ---------------- $template->what = user Set what to user $template->what = group Set what to group Actual result: -------------- $template->what = user Set what to user $template->what = group Set &what; to group ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29767&edit=1

« previous php.bugs (#64985) next »