note 71194 added to language.oop5.basic

From: Date: Wed, 15 Nov 2006 21:16:36 +0000
Subject: note 71194 added to language.oop5.basic
Groups: php.notes 
Request: Send a blank email to php-notes+get-119760@lists.php.net to get a copy of this message
The best alternatives I think one has right now to nest a class are: 1- create the nested class in an external file and 'include' that file inside a nesting class function. I prefer to use a static function for this. 2- put the nested class definition in a string inside a nesting class function and use the 'eval' keyword to define the class. <?php class MyParent{ public function parentFunction( ){ } public static function nestedClasses(){ eval(' class MyChild{ function __construct(){ echo "this is a nested class"; } public function childFunction( ) { } } '); } } MyParent::nestedClasses(); $y = new MyChild(); ?> ---- Server IP: 66.163.161.117 Probable Submitter: 216.99.43.20 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.basic.php Edit -- https://master.php.net/note/edit/71194 Del: integrated -- https://master.php.net/note/delete/71194/integrated Del: useless -- https://master.php.net/note/delete/71194/useless Del: bad code -- https://master.php.net/note/delete/71194/bad+code Del: spam -- https://master.php.net/note/delete/71194/spam Del: non-english -- https://master.php.net/note/delete/71194/non-english Del: in docs -- https://master.php.net/note/delete/71194/in+docs Del: other reasons-- https://master.php.net/note/delete/71194 Reject -- https://master.php.net/note/reject/71194 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119760) next »