PHP笔记
来自Jack's Lab
(版本间的差异)
(→资源) |
|||
| 第1行: | 第1行: | ||
| + | == XML == | ||
| + | |||
| + | <source lang=php> | ||
| + | <?php | ||
| + | $xmldata = <<<XML | ||
| + | <?xml version="1.0" encoding="utf-8" ?> | ||
| + | <root> | ||
| + | <gateway_id>2</gateway_id> | ||
| + | <data operation="report"> | ||
| + | </data> | ||
| + | </root> | ||
| + | XML; | ||
| + | |||
| + | $root = new SimpleXMLElement($xmldata); | ||
| + | |||
| + | echo "Gateway ID: " . $root->gateway_id . "\n"; | ||
| + | ?> | ||
| + | </source> | ||
| + | |||
| + | <br> | ||
| + | |||
== 正则表达式 == | == 正则表达式 == | ||
2017年8月11日 (五) 08:42的版本
1 XML
<?php $xmldata = <<<XML <?xml version="1.0" encoding="utf-8" ?> <root> <gateway_id>2</gateway_id> <data operation="report"> </data> </root> XML; $root = new SimpleXMLElement($xmldata); echo "Gateway ID: " . $root->gateway_id . "\n"; ?>
2 正则表达式
'/Result:\s*[^0]{1}\s*row.*<table>.*<tr>.+<\/tr>[^<]*<tr\s?>(.+)<\/tr>/s' -----> *, + 都是最大匹配
适当就好要用 *? 和 +?
'/Result:\s*[^0]{1}\s*row.*<table>.*?<tr>.+?<\/tr>[^<]*?<tr\s?>(.+?)<\/tr>/s'
3 资源
- PHP Tutorial: http://www.tutorialspoint.com/php/index.htm
- PHP 在线执行: http://writecodeonline.com/php/
- PHP 参考手册: http://www.php.net/manual/zh/funcref.php