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