When you declare one variable, the initial type is null, but the type can be changed by assign statement.
global $my_var;
echo gettype($my_var);
$my_var = new stdClass();
$my_var->name = 'test';
$my_var->city = 'china';
//$my_var['weather']= 'cold';
echo gettype($my_var);
var_dump($my_var);
本文介绍了在PHP中如何声明变量并改变其类型。通过实例演示了变量从无类型到对象类型的转变过程,并展示了如何给对象添加属性。
6521

被折叠的 条评论
为什么被折叠?



