<?php
/*
$reg = '/(?:<p>)?[(press-feed-all)/';
$str = '[press-feed-all';
preg_match_all($reg,$str,$matches);
var_dump($matches);
array (size=2)
0 =>
array (size=1)
0 => string '[press-feed-all' (length=15)
1 =>
array (size=1)
0 => string 'press-feed-all' (length=14) */
/* $reg = '/(?:<p>)?[(press-feed-all)/';
$str = 'press-feed-all';
preg_match_all($reg,$str,$matches);
var_dump($matches);
array (size=2)
0 =>
array (size=0)
empty
1 =>
array (size=0)
empty */
/* $reg = '/(?:<p>)?[(press-feed-all)/';
$str = '<p>[press-feed-all';
preg_match_all($reg,$str,$matches);
var_dump($matches);
array (size=2)
0 =>
array (size=1)
0 => string '<p>[press-feed-all' (length=18)
1 =>
array (size=1)
0 => string 'press-feed-all' (length=14) */
//终于搞清楚:
// 1 preg_match_all, preg在前 参数问题
// 2 ?:的意思就是说 匹不匹配都行 但肯定不纳入子()元素
/* $reg = '/(<p>)?[(press-feed-all)/';
$str = '<p>[press-feed-all';
preg_match_all($reg,$str,$matches);
var_dump($matches);
array (size=3)
0 =>
array (size=1)
0 => string '<p>[press-feed-all' (length=18)
1 =>
array (size=1)
0 => string '<p>' (length=3)
2 =>
array (size=1)
0 => string 'press-feed-all' (length=14) */
// 参数0下所有匹配到的
// 参数1下是非()里面匹配到的
// 参数2是所有()并且要被匹配到的元素集合
/* $reg = '/(<p>)?[(press-feed-all)/';
$str = '<p>[press-feed-all[press-feed-all';
preg_match_all($reg,$str,$matches);
var_dump($matches);
array (size=3)
0 =>
array (size=2)
0 => string '<p>[press-feed-all' (length=18)
1 => string '[press-feed-all' (length=15)
1 =>
array (size=2)
0 => string '<p>' (length=3)
1 => string '' (length=0)
2 =>
array (size=2)
0 => string 'press-feed-all' (length=14)
1 => string 'press-feed-all' (length=14) */
/* $reg = '/(?:<p>)?[(press-feed-?(all)?):([^:]]*):?([^:]]*):?([^]]*)](?:</p>)?/i';
$str = '[press-feed-all:abc:abc:abc]<p>';
preg_match_all($reg,$str,$matches);
var_dump($matches);
array (size=6)
0 =>
array (size=1)
0 => string '[press-feed-all:abc:abc:abc]' (length=28)
1 =>
array (size=1)
0 => string 'press-feed-all' (length=14)
2 =>
array (size=1)
0 => string 'all' (length=3)
3 =>
array (size=1)
0 => string 'abc' (length=3)
4 =>
array (size=1)
0 => string 'abc' (length=3)
5 =>
array (size=1)
0 => string 'abc' (length=3) */
/* $reg = '/(?:<p>)?[(press-feed-?(all)?):([^:]]*):?([^:]]*):?([^]]*)](?:</p>)?/i';
$str = '[press-feed-all:abc]<p>';
preg_match_all($reg,$str,$matches);
var_dump($matches);
array (size=6)
0 =>
array (size=1)
0 => string '[press-feed-all:abc]' (length=20)
1 =>
array (size=1)
0 => string 'press-feed-all' (length=14)
2 =>
array (size=1)
0 => string 'all' (length=3)
3 =>
array (size=1)
0 => string 'abc' (length=3)
4 =>
array (size=1)
0 => string '' (length=0)
5 =>
array (size=1)
0 => string '' (length=0) */
/* $arr = [];
if(is_array($arr)){
var_dump('[] is an array');
}
'[] is an array' (length=14) */
//example-end的中横线有没有都是可以的
/* $reg = '/[example-end]/';
$str = '[example-end]';
preg_match_all($reg,$str,$matches);
var_dump($matches); */
//如果不匹配就打印出0
//也许匹配就打印出1?
/* $reg = '/[example-end]/';
$str = 'abc';
$result = preg_match_all($reg,$str,$matches);
var_dump($matches);
var_dump($result);
array (size=1)
0 =>
array (size=0)
empty
C:wamp64www est.php:143:int 0 */
/* $reg = '/(?:<p>)?[example]([sS
]+?)[example-end](?:</p>)?/i';
$str = '[example]
Some markup
[example-end]';
$res = preg_match_all($reg,$str,$matches);
var_dump($matches);
var_dump($res);
array (size=2)
0 =>
array (size=1)
0 => string '[example]
Some markup
[example-end]' (length=39)
1 =>
array (size=1)
0 => string '
Some markup
' (length=17)
C:wamp64www est.php:160:int 1 */
//NN会在屏幕出现一个大的段落格式
/* $node_body = '<p>[example]
Some markup
[example-end]</p>';
if (strpos($node_body, '[example]') !== FALSE && preg_match_all('/(?:<p>)?[example]([sS
]+?)[example-end](?:</p>)?/i', $node_body, $ex_matches)) {
$ex_embed = array();
$ex_count = count($ex_matches[0]);
var_dump($ex_matches);
for ($i = 0; $i < $ex_count; $i++) {
$ex_embed[$i] = $ex_matches[1][$i] . "
[encode]" . $ex_matches[1][$i] . '[encode-end]';
}
//因为只有一个()所以只有最大就是$matches[1]没有更大的了
$node_body = str_replace($ex_matches[0], $ex_embed, $node_body);
}
var_dump($node_body); */
//在windows下是这样的输出
//如果是单引号是没有效果的
//双引号是有效果的
//双引号就认为字符不仅是字符
//在能力范围内还要去解析
//单引号
/* $ab = str_replace("
","--","a
b");
var_dump($ab);
string 'a
--b' (length=5) */
/*
is used for Unix systems (including Linux, and OSX).
is mainly used on Windows.
is used on really old Macs. */
//echo 'Hello, world!' . "xA" . 'Hello, world!';
//没有反应
/* $str = '"<abc> ';
$chars = htmlspecialchars($str);
$ent = htmlentities($str);
var_dump($chars);
var_dump($ent);
string '"<abc> ' (length=18)
string '"<abc> ' (length=18)
出来的结果是一样的 */
/* htmlspecialchars
就是转换5个字符: 大小于, 单双号, &
将特殊字符转换为 HTML 实体
也就是说: &,", ',<,> 就是实体 */
/* $ch = htmlspecialchars('a"b c',ENT_QUOTES,'utf-8');
var_dump($ch);
string 'a"b c' (length=10) */
/* $str='<a href="test.html">测试页面</a>';
echo htmlentities($str); */
/* echo htmlentities('[]');
echo htmlspecialchars('[]');
//出来的结果是一样的 感觉到了高版本就没有区别了*/
//tbd
//to be determined 待决定
//网关
//用于连接局域网和Internet
/* if(empty($abc['abc'])){
var_dump('$abc[abc] is empty');
}
//'$abc[abc] is empty' (length=18)
//就是说用empty判断的时候不会因为没有这个值而报错 */
/* $a = 'aa';
$b = 'bb';
$ab = compact('a','b');
var_dump($ab);
array (size=2)
'a' => string 'aa' (length=2)
'b' => string 'bb' (length=2) */
/* $ab = compact('a','b');
var_dump($ab);
array (size=0)
empty */
/* $a = 'a';
$ab = compact('a','b');
var_dump($ab);
array (size=1)
'a' => string 'a' (length=1) */
/* if($abc['abc'] != 'abc'){
var_dump('abc is not abc');
}
//Notice: Undefined variable: abc
//这个地方还是要报错的 因为下标abc不存在
*/
//echo 'abc';
/* $obj = new stdClass();
$obj->abc = null;
if(property_exists($obj, 'abc')){
var_dump('property exists......');
}
C:wamp64www est.php:285:string 'property exists......' (length=21) */
/* $obj = new stdClass();
if(empty($obj->abc)){
var_dump('aaaaa');
}
//C:wamp64www est.php:291:string 'aaaaa' (length=5)
运行是没有问题的
*/
/* $arr = ['a','b','c'];
$abc = reset($arr);
var_dump($abc);
string 'a' (length=1) */
/* $arr = [];
if(is_array($arr)){
var_dump('is array');
}
string 'is array' (length=8) */
/* $namespaces = ['a'=>'a','b'=>'b'];
$ns = new ArrayObject($namespaces);
var_dump($ns);
object(ArrayObject)[1]
private 'storage' =>
array (size=2)
'a' => string 'a' (length=1)
'b' => string 'b' (length=1) */
//C:ProgramDataOracleJavajavapath;C:Program Files (x86)RSA SecurID Token Common;%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;%SYSTEMROOT%System32WindowsPowerShellv1.0;C:Program Files (x86)WebExProductivity Tools;C:Program Files (x86)SafeComSafeComPrintClient;C:Program Files (x86)CheckPointEndpoint SecurityEndpoint Commonin;C:Program Files (x86)SennheiserSoftphoneSDK;C:Program FilesGitcmd;C:wamp64inphpphp5.6.31;C:ProgramDataComposerSetupin;C:UsersqqinAppDataRoamingComposervendordrushdrush;C:wamp64inmysqlmysql5.7.19inmysql.exe;C:wamp64inapacheapache2.4.27inhttpd.exe;C:wamp64inmysqlmysql5.7.19in;