Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php oop


Andomi Ansari
  <?php
class Parent {
	public function __construct() {
    	echo "Parent Created
";
    }
  	public function sayHello() {
    	echo "Hello, from Parent
";
    }
  	public function eitherHello() {
    	echo "Hello, from Parent and child if desired
";
    }
}
class Child extends Parent {
	public function __construct() {
    	echo "Child Created
";
    }
  	public function sayHello() {
    	echo "Hello, from Child
";
    }
}
$p = new Parent();	// Parent Created
$c = new Child();	// Child Created
$p->sayHello(); 	// Hello, from Parent
$c->sayHello();		// Hello, from Child
$p->eitherHello();	// Hello, from Parent and child if desired
$c->eitherHello();	// Hello, from Parent and child if desired
?>


 
PREVIOUS NEXT
Tagged: #php #oop
ADD COMMENT
Topic
Name
5+8 =