note 62795 added to language.oop5.basic

From: Date: Thu, 09 Mar 2006 19:48:28 +0000
Subject: note 62795 added to language.oop5.basic
Groups: php.notes 
Request: Send a blank email to php-notes+get-105161@lists.php.net to get a copy of this message
Searching the php site for the string "variable classes" did not produce anything, but the note below by mrich at runbox dot removethis dot com indicates that the concept, analogous to "variable functions", "variable methods", and "variable variables", is indeed supported by the new operator. <? class MyClass { /* ... */ } $y = new 'MyClass'; // rejected $x = 'MyClass'; $y = new $x; // ok $y = new $x(); // ok function NewObj( $className ) { $argv = func_get_args(); return call_user_func_array( array( new ReflectionClass( $className ), 'newInstance' ), array_shift( $argv ) ); } $y = NewObj( $x ); // ok $y = NewObj( 'MyClass' ); // ok ?> ---- Server IP: 66.163.161.117 Probable Submitter: 207.171.180.101 ---- 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/62795 Del: integrated -- http://master.php.net/note/delete/62795/integrated Del: useless -- http://master.php.net/note/delete/62795/useless Del: bad code -- http://master.php.net/note/delete/62795/bad+code Del: spam -- http://master.php.net/note/delete/62795/spam Del: non-english -- http://master.php.net/note/delete/62795/non-english Del: in docs -- http://master.php.net/note/delete/62795/in+docs Del: other reasons-- http://master.php.net/note/delete/62795 Reject -- http://master.php.net/note/reject/62795 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#105161) next »