Detailed explanation of how PHP determines whether a str string is data in xml format

黄舟
Release: 2023-03-14 13:44:01
Original
2323 people have browsed it

这篇文章主要介绍了php判断str字符串是否是xml格式数据的方法,结合实例形式较为详细的分析了php采用自定义函数针对xml格式数据进行验证的相关操作技巧,需要的朋友可以参考下

本文实例讲述了php判断str字符串是否是xml格式数据的方法。分享给大家供大家参考,具体如下:



  
    Jack Herrington
    PHP Hacks
    O'Reilly
  
  
    Jack Herrington
    Podcasting Hacks
    O'Reilly
  
  
    XML数据
    脚本之家
    tools.jb51.net
  

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格式数据";
}else{
 echo "\$xmlstr不是xml格式数据";
}
echo "
"; if(xml_parser($jsonstr)){ echo "\$jsonstr是xml格式数据"; }else{ echo "\$jsonstr不是xml格式数据"; } ?>
Copy after login

运行结果:

$xmlstr是xml格式数据
$jsonstr不是xml格式数据
Copy after login

The above is the detailed content of Detailed explanation of how PHP determines whether a str string is data in xml format. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!