Lectures List
capscom technology computer course almora

PHP OOP Class and objects

Class is a blueprint or skeleton for an object.

Class members 

Variables and methods declared within a class is called a member of the class.
 
Variable is called member variable, and method is called member method.
 

Member variable.

Declare member variable
public $name, $age;
Member methods 
public function msg(){

}

Object 

It is a real entity that has properties and methods.
 
Create object
 
$object = new ClassName();
Example
$person = new Person();

Example

class Person{
	public $name, $age;
	public function setDetails($name, $age){
		$this->name = $name;
		$this->age = $age;
	}
	public function display(){
		echo "
		Name: $this->name <br/>
		Age: $this->age <br/>
		";
	}
}

$user = new Person();
$user->setDetails("Rama", 20);
$user->display();
Author/Written by: Mr Hemant Singh (Founder)
Terms & Conditions CAPSCOM TECHNOLOGY Pvt. Ltd. का बेहतर रूप से संचालन करने के लिए यहॉ कुछ नियमें और शर्ते लागू है अगर आप कैप्सकॉम टैक्नोलॉजी में पढ़ रहे है तो यह आप पर लागू होता है।