php object
snippet in php

php empty object

user8553

$x = new stdClass();

make a object php

user658

   $object = new stdClass();
   $object->property = 'Here we go';

   var_dump($object);
   /*
   outputs:

   object(stdClass)#2 (1) {
      ["property"]=>
      string(10) "Here we go"
    }
   */

object php

user6990

//object init
  $object = (object) [
    'propertyOne' => 'foo',
    'propertyTwo' => 42,
  ];

php object

user215

//create a person object in PHP
$person=new stdClass();
$person->firstName="Chuck";
$person->lastName="Bartowski";
$person->age=27;

print_r($person);

php object

user4416

$o= new \stdClass();
$o->a = 'new object';

OR

$o = (object) ['a' => 'new object'];

php object

user2757

$obj = [
  "example1" => 1,
  "example2" => "two",
  "example3" => [
    "example4": true
  ]
]