使用php怎么判斷str字符串是不是xml格式數(shù)據(jù)?相信很多沒有經(jīng)驗(yàn)的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。
具體如下:
ETO; $jsonstr='{ "tools": [ { "name":"css format" , "site":"http://tools.jb51.net/code/css" }, { "name":"json format" , "site":"http://tools.jb51.net/code/json" }, { "name":"pwd check" , "site":"http://tools.jb51.net/password/my_password_safe" } ] }'; if(xml_parser($xmlstr)){ echo "\$xmlstr是xml格式數(shù)據(jù)"; }else{ echo "\$xmlstr不是xml格式數(shù)據(jù)"; } echo " Jack Herrington PHP Hacks O'Reilly Jack Herrington Podcasting Hacks O'Reilly XML數(shù)據(jù) 創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司, tools.jb51.net
"; if(xml_parser($jsonstr)){ echo "\$jsonstr是xml格式數(shù)據(jù)"; }else{ echo "\$jsonstr不是xml格式數(shù)據(jù)"; } ?>
運(yùn)行結(jié)果:
$xmlstr是xml格式數(shù)據(jù) $jsonstr不是xml格式數(shù)據(jù)
看完上述內(nèi)容,你們掌握使用php怎么判斷str字符串是不是xml格式數(shù)據(jù)的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!