PHP笔记
来自Jack's Lab
(版本间的差异)
(未显示1个用户的12个中间版本) | |||
第1行: | 第1行: | ||
+ | == 数据类型数组 == | ||
+ | |||
+ | https://www.php.net/manual/zh/language.types.array.php | ||
+ | |||
+ | <br> | ||
+ | |||
+ | == XML == | ||
+ | |||
+ | <source lang=php> | ||
+ | <?php | ||
+ | $xmldata = <<<XML | ||
+ | <?xml version="1.0" encoding="utf-8" ?> | ||
+ | <root> | ||
+ | <gateway_id>1122</gateway_id> | ||
+ | <data operation="report"> | ||
+ | </data> | ||
+ | </root> | ||
+ | XML; | ||
+ | |||
+ | $root = new SimpleXMLElement($xmldata); | ||
+ | |||
+ | echo "Gateway ID: " . $root->gateway_id . "\n"; | ||
+ | ?> | ||
+ | </source> | ||
+ | |||
+ | <br> | ||
+ | |||
== 正则表达式 == | == 正则表达式 == | ||
+ | <pre> | ||
'/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' -----> *, + 都是最大匹配 | ||
+ | </pre> | ||
第9行: | 第38行: | ||
'/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' | ||
</pre> | </pre> | ||
+ | |||
+ | <br><br> | ||
+ | |||
+ | == Time == | ||
+ | |||
+ | <source lang=php> | ||
+ | <?php | ||
+ | date_default_timezone_set("UTC"); | ||
+ | echo "UTC:".time(); | ||
+ | echo "<br>"; | ||
+ | |||
+ | date_default_timezone_set("Asia/Shanghai"); | ||
+ | echo "Asia/Shanghai:".time(); | ||
+ | echo "<br>"; | ||
+ | ?> | ||
+ | |||
+ | |||
+ | UTC:1526196418 | ||
+ | Asia/Shanghai:1526196418 | ||
+ | |||
+ | |||
+ | int time ( void ) | ||
+ | // Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). | ||
+ | // The function time() returns always timestamp that is timezone independent (=UTC). | ||
+ | |||
+ | </source> | ||
+ | |||
<br><br> | <br><br> | ||
第21行: | 第77行: | ||
* PHP 参考手册: http://www.php.net/manual/zh/funcref.php | * PHP 参考手册: http://www.php.net/manual/zh/funcref.php | ||
+ | |||
+ | * http://www.w3school.com.cn/php/php_cookies.asp | ||
+ | |||
+ | * http://www.w3school.com.cn/php/php_operators.asp | ||
+ | |||
+ | * http://www.tutorialspoint.com/execute_php_online.php | ||
+ | |||
+ | |||
+ | * http://www.w3school.com.cn/tiy/t.asp?f=html5_input_placeholder | ||
<br><br> | <br><br> | ||
<br><br> | <br><br> |
2021年10月3日 (日) 08:27的最后版本
目录 |
[编辑] 1 数据类型数组
https://www.php.net/manual/zh/language.types.array.php
[编辑] 2 XML
<?php $xmldata = <<<XML <?xml version="1.0" encoding="utf-8" ?> <root> <gateway_id>1122</gateway_id> <data operation="report"> </data> </root> XML; $root = new SimpleXMLElement($xmldata); echo "Gateway ID: " . $root->gateway_id . "\n"; ?>
[编辑] 3 正则表达式
'/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'
[编辑] 4 Time
<?php date_default_timezone_set("UTC"); echo "UTC:".time(); echo "<br>"; date_default_timezone_set("Asia/Shanghai"); echo "Asia/Shanghai:".time(); echo "<br>"; ?> UTC:1526196418 Asia/Shanghai:1526196418 int time ( void ) // Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). // The function time() returns always timestamp that is timezone independent (=UTC).
[编辑] 5 资源
- PHP Tutorial: http://www.tutorialspoint.com/php/index.htm
- PHP 在线执行: http://writecodeonline.com/php/
- PHP 参考手册: http://www.php.net/manual/zh/funcref.php