Share on Google+Share on Google+

PHP Class Object

Advertisement
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.

Advertisements

Advertisement

Posted on: February 17, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.