Hi list,
this is not a problem, but a nice feature of OOP, I found today. Maybe it is
useful for someone:
<?php
// class test
class Basis
{
var $name = "Basis";
function Basis($typ = false)
{
switch ($typ)
{
case "A":
$this = new Basis_A();
break;
case "B":
$this = new Basis_B();
break;
}
}
function print_name()
{
echo $this->name . "<br>";
}
}
class Basis_A extends Basis
{
var $name = "Basis_A";
}
class Basis_B extends Basis
{
var $name = "Basis_B";
}
$my_basis_1 = new Basis();
$my_basis_2 = new Basis("A");
$my_basis_3 = new Basis("B");
$my_basis_1->print_name();
$my_basis_2->print_name();
$my_basis_3->print_name();
?>
The point is, that the class morphs itself into another class in the
constructor.
Hope it helps someone,
Moritz.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]