note 64404 added to language.oop
| From: | chris at simplekiosks dot com | Date: | Thu, 13 Apr 2006 16:31:43 +0000 |
| Subject: | note 64404 added to language.oop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107998@lists.php.net to get a copy of this message | ||
I took the above examples and extented them slightly to also allow you to run any function in the
subclass without having to first declare it in the main class.
Enjoy
<?php
class mainClass
{
/*
* Class loading function.
*
*
*
*
*/
var $module;
function LoadClass($loadModule)
{
$this->module = new $loadModule; // this is much better
}
function RunFunction($FunctionName)
{
$this->module->$FunctionName();
}
function ListFunctions()
{
}
// function out()
//{
// $this->module->out();
// }
}
class subclass
{
function out()
{
echo "Worked";
}
function NewFunction()
{
echo "<br>Good Lord<br>";
}
function ThirdFunction()
{
echo "<br>eh....<br>";
}
}
echo "Start of class manulapations<br>";
//$loadModule = new subclass;
$mainclass=new mainClass;
$mainclass->LoadClass("subclass");
//$mainclass->out();
$mainclass->RunFunction('NewFunction');
//$mainclass->ThirdFunction();
echo "End of class manulapation<br>";
?>
----
Server IP: 64.71.164.2
Probable Submitter: 84.9.201.183
----
X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.oop.php
Edit -- http://master.php.net/note/edit/64404
Del: integrated -- http://master.php.net/note/delete/64404/integrated
Del: useless -- http://master.php.net/note/delete/64404/useless
Del: bad code -- http://master.php.net/note/delete/64404/bad+code
Del: spam -- http://master.php.net/note/delete/64404/spam
Del: non-english -- http://master.php.net/note/delete/64404/non-english
Del: in docs -- http://master.php.net/note/delete/64404/in+docs
Del: other reasons-- http://master.php.net/note/delete/64404
Reject -- http://master.php.net/note/reject/64404
Search -- http://master.php.net/manage/user-notes.php