1<?php
2class Parent {
3 public function __construct() {
4 echo "Parent Created\n";
5 }
6 public function sayHello() {
7 echo "Hello, from Parent\n";
8 }
9 public function eitherHello() {
10 echo "Hello, from Parent and child if desired\n";
11 }
12}
13class Child extends Parent {
14 public function __construct() {
15 echo "Child Created\n";
16 }
17 public function sayHello() {
18 echo "Hello, from Child\n";
19 }
20}
21$p = new Parent(); // Parent Created
22$c = new Child(); // Child Created
23$p->sayHello(); // Hello, from Parent
24$c->sayHello(); // Hello, from Child
25$p->eitherHello(); // Hello, from Parent and child if desired
26$c->eitherHello(); // Hello, from Parent and child if desired
27?>
1The PHP Object-Oriented Programming concepts are:
2Class
3Objects
4Inheritance
5Interface
6Abstraction
7Magic Methods
1Well Explained in here:
2https://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
3@Zenonymous
1<?php
2 class Mobile {
3 /* Member variables */
4 var $price;
5 var $title;
6 /* Member functions */
7 function setPrice($par){
8 $this->price = $par;
9 }
10 function getPrice(){
11 echo $this->price ."
12";
13 }
14 function setName($par){
15 $this->title = $par;
16 }
17 function getName(){
18 echo $this->title ."
19";
20 }
21 }
22$Samsung = new Mobile();
23$Xiaomi = new Mobile();
24$Iphone = new Mobile();
25$Samsung->setName( "SamsungS8 );
26$Iphone->setName( "Iphone7s" );
27$Xiaomi->setName( "MI4" );
28$Samsung->setPrice( 90000 );
29$Iphone->setPrice( 65000 );
30$Xiaomi->setPrice( 15000 );
31Now you call another member functions to get the values set by in above example
32$Samsung->getName();
33$Iphone->getName();
34$Xiaomi->getName();
35$Samsung->getPrice();
36$Iphone->getPrice();
37$Xiaomi->getPrice();
38?>
39