note 67906 added to language.oop5.basic

From: Date: Thu, 06 Jul 2006 08:51:09 +0000
Subject: note 67906 added to language.oop5.basic
Groups: php.notes 
Request: Send a blank email to php-notes+get-114489@lists.php.net to get a copy of this message
If you have to declare a class in runtime and be able to use various types (in my case they where sharing an interface) by just knowing the name of the class you can do like this: <?php class foo { public $bar = "hest"; } $className = "foo"; $instance = new $className(); var_dump($instance); ?> I had a lot use of this in a complex plugin-based managment system. Jonas ---- Server IP: 129.16.214.50 Probable Submitter: 82.182.13.58 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.basic.php Edit -- http://master.php.net/note/edit/67906 Del: integrated -- http://master.php.net/note/delete/67906/integrated Del: useless -- http://master.php.net/note/delete/67906/useless Del: bad code -- http://master.php.net/note/delete/67906/bad+code Del: spam -- http://master.php.net/note/delete/67906/spam Del: non-english -- http://master.php.net/note/delete/67906/non-english Del: in docs -- http://master.php.net/note/delete/67906/in+docs Del: other reasons-- http://master.php.net/note/delete/67906 Reject -- http://master.php.net/note/reject/67906 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114489) next »