declare object php code example
Example 1: make a object php
$object = new stdClass();
$object->property = 'Here we go';
var_dump($object);
/*
outputs:
object(stdClass)#2 (1) {
["property"]=>
string(10) "Here we go"
}
*/
Example 2: object php
//object init
$object = (object) [
'propertyOne' => 'foo',
'propertyTwo' => 42,
];
Example 3: how to create object in php
//define a class
class MyClass{
//create properties, constructor or methods
}
//create object using "new" keyword
$object = new MyClass();
//or wihtout parenthesis
$object = new MyClass;