note 103160 added to language.oop5.inheritance
| From: | anhsang9x at gmail dot com | Date: | Tue, 29 Mar 2011 15:34:10 +0000 |
| Subject: | note 103160 added to language.oop5.inheritance | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178306@lists.php.net to get a copy of this message | ||
This is the two way build class. What do you mean?
<?php
class Class1
{
public function PrintOutClass1()
{
echo "This is a Class1</br>";
}
}
class Class2 extends Class1
{
public function PrintOutClass2()
{
echo "This is a Class2</br>";
}
}
//Class3 inheritance Class1, 2
class Class3 extends Class2
{
public function PrintOutClass3()
{
echo "This is a Class3</br>";
}
}
//Class4 will make other define class
class Class4
{
private $name_class;
public function MakeClass($name_class)
{
$this->name_class = $name_class;
return new $this->name_class; //declare new class defined
}
public function PrintOutClass4()
{
echo "This is a Class4</br>";
}
}
//Use Class 3
$class3 = new Class3();
$class3->PrintOutClass3();
$class3->PrintOutClass2();
$class3->PrintOutClass1();
//Use Class 4
$class4 = new Class4();
$class4->PrintOutClass4();
$class2 = $class4->MakeClass("Class2");
$class2->PrintOutClass2();
$class3 = $class4->MakeClass("Class3");
$class3->PrintOutClass1();
//Finish What do you thinking?
?>
Return on page
This is a Class3
This is a Class2
This is a Class1
This is a Class4
This is a Class2
This is a Class1
----
Server IP: 69.147.83.197
Probable Submitter: 123.20.73.192
----
Manual Page -- http://www.php.net/manual/en/language.oop5.inheritance.php
Edit -- https://master.php.net/note/edit/103160
Del: integrated -- https://master.php.net/note/delete/103160/integrated
Del: useless -- https://master.php.net/note/delete/103160/useless
Del: bad code -- https://master.php.net/note/delete/103160/bad+code
Del: spam -- https://master.php.net/note/delete/103160/spam
Del: non-english -- https://master.php.net/note/delete/103160/non-english
Del: in docs -- https://master.php.net/note/delete/103160/in+docs
Del: other reasons-- https://master.php.net/note/delete/103160
Reject -- https://master.php.net/note/reject/103160
Search -- https://master.php.net/manage/user-notes.php