PHP Class Object


 

PHP Class Object

In object oriented programming a class can be an abstract data type, blue print or template. You could consider the name of a class as noun like name of a person, place or thing. For example Fruit is a class, where apple, orange are the object of this class.

In object oriented programming a class can be an abstract data type, blue print or template. You could consider the name of a class as noun like name of a person, place or thing. For example Fruit is a class, where apple, orange are the object of this class.

PHP Class Object:

In object oriented programming a class can be an abstract data type, blue print or template. You could consider the name of a class as noun like name of a person, place or thing.  For example Fruit is a class, where apple, orange are the object of this class.

Object is the instantiate of a class. A class consists of a member variable and methods. In PHP we need to declare the access specifiers (public, private, or protected) separately for

PHP Object Class Example:

<?php

class A

{

public function disp(){

echo "Inside the class<br/>";

}}

$a=new A();

$a->disp();

A::disp();

?>

Output:

Inside the class
Inside the class

Explanation:

In the above programming we create a class named A, it has a publically declared function disp(), on the outer side of the class we instantiate the object $a, we  call the function disp with -> operator. Any class can access it's member using :: operator.

Ads