Astro
0
Q:

java php object

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

OR

$o = (object) ['a' => 'new object'];
1
//object init
  $object = (object) [
    'propertyOne' => 'foo',
    'propertyTwo' => 42,
  ];
0
//create a person object in PHP
$person=new stdClass();
$person->firstName="Chuck";
$person->lastName="Bartowski";
$person->age=27;

print_r($person);

-1
$obj = [
  "example1" => 1,
  "example2" => "two",
  "example3" => [
    "example4": true
  ]
]
0
$a = array('foo' => 'bar');
$o = (object) $a;
var_dump($o instanceof stdClass); // bool(true)
var_dump($o->foo); // string(3) "bar"
0

New to Communities?

Join the community