Search
 
SCRIPT & CODE EXAMPLE
 

PHP

object oriented programming php

<?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
?>
Comment

oop php

<?php
class Fruit {
  // Properties
  public $name;
  public $color;

  // Methods
  function set_name($name) {
    $this->name = $name;
  }
  function get_name() {
    return $this->name;
  }
  function set_color($color) {
    $this->color = $color;
  }
  function get_color() {
    return $this->color;
  }
}

$apple = new Fruit();
$apple->set_name('Apple');
$apple->set_color('Red');
echo "Name: " . $apple->get_name();
echo "<br>";
echo "Color: " .  $apple->get_color();
?>
 
Comment

oop php

Well Explained in here: 
https://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
@Zenonymous
Comment

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
?>


Comment

oop php

<?php
   class Mobile {
      /* Member variables */
      var $price;
      var $title;
      /* Member functions */
      function setPrice($par){
         $this->price = $par;
      }
      function getPrice(){
         echo $this->price ."
";
      }
      function setName($par){
         $this->title = $par;
      }
      function getName(){
         echo $this->title ."
";
      }
   }
$Samsung = new Mobile();
$Xiaomi = new Mobile();
$Iphone = new Mobile();
$Samsung->setName( "SamsungS8 );
$Iphone->setName( "Iphone7s" );
$Xiaomi->setName( "MI4" );
$Samsung->setPrice( 90000 );
$Iphone->setPrice( 65000 );
$Xiaomi->setPrice( 15000 );
Now you call another member functions to get the values set by in above example
$Samsung->getName();
$Iphone->getName();
$Xiaomi->getName();
$Samsung->getPrice();
$Iphone->getPrice();
$Xiaomi->getPrice();
?>
Comment

PREVIOUS NEXT
Code Example
Php :: append in php 
Php :: laravel collection first 
Php :: how to pass parameters to relationships laravel 
Php :: PHP strrpos — Find the position of the last occurrence of a substring in a string 
Php :: laravel pagination with search filter 
Php :: number data type in laravel migration 
Php :: rendering json in laravel 
Php :: php select using prepared statements 
Php :: wordpress get wp roles 
Php :: how to check if file is empty in php 
Php :: php echo html and variable 
Php :: how to use wherehas in laravel 
Php :: how to get the previous page url in php 
Php :: change or set post type wordpress 
Php :: clear cache without using composer in laravel 8 
Php :: php lcfirst 
Php :: laravel_login 
Php :: laravel textarea value 
Php :: how to get value in to radio button php 
Php :: laravel request file empty 
Php :: get romawi number php 
Php :: laravel migration text length 
Php :: php public folder 
Php :: laravel call controller method from another controller 
Php :: REFERRER CODEIGNITER 3 
Php :: laravel_login1 
Php :: laravel eloquent with query parameter 
Php :: pest check url status 
Php :: assocititive multi array compare php 
Php :: add class to row laravel 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =