note 53443 added to language.oop5

From: Date: Wed, 01 Jun 2005 20:52:11 +0000
Subject: note 53443 added to language.oop5
Groups: php.notes 
Request: Send a blank email to php-notes+get-89753@lists.php.net to get a copy of this message
This might be trivial but took me some time to figure out. I needed to create an object of a class, but did not know the name of the class in advance. While vor methods/variables one can use strings (such as in $object->$variable), the following is not allowed: $a = new $class; The only way I could achieve that was to use eval: eval("\$a = new $class;"); ---- Manual Page -- http://www.php.net/manual/en/language.oop5.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53443 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53443&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53443&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53443&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53443&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53443&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53443&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#89753) next »