我试图解析一个包含基本属性的简单 xml 字符串
<hash>
<engine-type>
I4 DI
</engine-type>
<body-style>
SAV 4D
</body-style>
<year>
2012
</year>
</hash>
当我试图打印出 xdebug 给出的这 2 个属性 engine-type 和 body-style 时,问题发生了
$result = simplexml_load_string($query);
$enginetype = $result->engine-type;
$bodystyle = $result->body-style ;
echo $enginetype .'<br />'. $bodystyle ;
这些是来自xdebug的错误
Notice: Use of undefined constant type - assumed 'type'
Notice: Use of undefined constant style - assumed 'style
当我尝试将它们保存到我的数据库中时,
其他属性值 0 就可以正常工作