Home Tutorial Php Phpbasics Tutorial PHP Object Type

 
 

PHP Object Type
Posted on: March 16, 2010 at 12:00 AM
This PHP tutorial will reveal some interesting concepts of object, in addition it gives you a glimpse on object in PHP.

PHP Object:

Class, and Object are one of the most important feature of OOP. Object is the instance of a class, to create an object we use new keyword.

In PHP we can convert any value to an object of a predefined class called stdClass. The value of any variable is stored in a member variable of the class (stdClass) called scalar.

Note: In the following examples there is no closing tag is included, since it is optional to add the end tag when no html coding is embedded.

PHP Object Example:

<?php

class A

{

private $a=12;

public function display()

{

echo $this->a;

}

}

$obj=new A();

$obj->display();

 

Output:

12

Example:

<?php

$obj=(object)34;

echo $obj->scalar;

 

Output:

34

Related Tags for PHP Object Type:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.