一、说明
- PHP使用
preg_match_all()
函数匹配字符串内容时报错:Warning: preg_match_all(): Unknown modifier ‘<’ - 翻译:
警告:preg_match_all():未知修饰符“<”
二、php代码
class Test
{
public function __construct()
{
}
public function start()
{
self::right2();
}
public function notModifier()
{
$html = self::getHtml();
$pattern = ";
preg_match_all($pattern, $html, $result);
var_export($result);die;
}
public function notModifier1()
{
$html = self::getHtml();
$pattern = "/;
preg_match_all($pattern, $html, $result);
var_export($result);die;
}
public function right1()
{
$html = self::getHtml();
$pattern = "/;
preg_match_all($pattern, $html, $result);
var_export($result);die;
}
public function right2()
{
$html = self::getHtml();
$pattern = "#;
preg_match_all($pattern, $html, $result);
var_export($result);die;
}
public function getHtml()
{
return $html = <<<EOF
EOF;
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
三、浏览器 右键 查看页面源代码 输出
array (
0 =>
array (
0 => ',
1 => ',
2 => ',
),
1 =>
array (
0 => 'http://www.*******/0/',
1 => 'http://www.*******/1/',
2 => 'http://www.*******/2/',
),
2 =>
array (
0 => '同是过路同做过梦 本应是一对',
1 => '人在少年梦中不觉 醒后要归去',
2 => '三餐一宿也共一双 到底会是谁',
),
)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20