Classes

From: Date: Tue, 05 Mar 2002 20:10:51 +0000
Subject: Classes
Groups: php.general 
Request: Send a blank email to php-general+get-87335@lists.php.net to get a copy of this message
Hallo! Can I from inside an Class Intialize other classes, and access them from the ordinary script? Page1.php <?PHP require_once("./myclass.inc"); $my = new MyClass; $my->init(); $fileread->readfile($file="myfile.txt"); ?> myclass.inc <?PHP class MyClass { var classes = Array( "classname1"=>"classkey1", "classname2"=>"classkey2", "classname3"=>"classkey3" ); function init() { foreach ($this->classes as $classname=>$classkey){ require_once("./$classname.inc"); eval("\$$classkey = new $classname;"); } } } ?> David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#87335) next »