要锟斤拷锟斤拷一锟斤拷锟铰的讹拷锟斤拷 object锟斤拷使锟斤拷 new 锟斤拷锟绞碉拷锟斤拷锟揭伙拷锟斤拷啵�
<?php
class foo
{
function do_foo()
{
echo "Doing foo.";
}
}
$bar = new foo;
$bar->do_foo();
?>
锟斤拷细锟斤拷锟桔参硷拷锟街诧拷锟斤拷锟斤拷锟斤拷锟斤拷锟�锟铰节★拷
锟斤拷锟斤拷锟揭伙拷锟斤拷锟斤拷锟阶拷锟斤拷啥锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷魏伪浠拷锟斤拷锟斤拷锟斤拷锟斤拷锟轿猴拷锟斤拷锟酵碉拷值锟斤拷转锟斤拷锟缴讹拷锟襟,斤拷锟结创锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷
stdClass 锟斤拷实锟斤拷锟斤拷锟斤拷锟斤拷锟街滴�
NULL
锟斤拷锟斤拷锟铰碉拷实锟斤拷为锟秸★拷
array 转锟斤拷锟斤拷 object 锟斤拷使锟斤拷锟斤拷锟斤拷为锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟接︼拷锟街碉拷锟阶拷猓猴拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤, 使锟斤拷 PHP 7.2.0 之前锟侥版本锟斤拷锟斤拷锟街硷拷只锟斤拷通锟斤拷锟斤拷锟斤拷锟斤拷锟绞★拷
<?php
$obj = (object) array('1' => 'foo');
var_dump(isset($obj->{'1'})); // PHP 7.2.0 锟斤拷锟斤拷锟� 'bool(true)'锟斤拷之前锟芥本锟斤拷锟斤拷锟� 'bool(false)'
var_dump(key($obj)); // PHP 7.2.0 锟斤拷锟斤拷锟� 'string(1) "1"'锟斤拷之前锟芥本锟斤拷锟� 'int(1)'
?>
锟斤拷锟斤拷锟斤拷锟斤拷值锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟皆憋拷锟斤拷锟斤拷锟� scalar锟斤拷
<?php
$obj = (object) 'ciao';
echo $obj->scalar; // outputs 'ciao'
?>