note 64404 deleted from language.oop by danbrown
| From: | danbrown@php.net | Date: | Sat, 07 Nov 2009 19:03:03 +0000 |
| Subject: | note 64404 deleted from language.oop by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162555@lists.php.net to get a copy of this message | ||
Note Submitter: chris at simplekiosks dot com
----
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>";
?>