一个非常基本的例子将不胜感激
要回答正则表达式部分:
preg_match('!<title>(.*)</title>!s', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>
4 bedroom
house
to rent in Caroline Place, Bayswater, W2 through Foxtons (Property to rent)</title>
<meta name="keywords" content="Houses" />', $matches);
print_r($matches);
/* output:
Array
(
[0] => <title>
4 bedroom
house
to rent in Caroline Place, Bayswater, W2 through Foxtons (Property to rent)</title>
[1] =>
4 bedroom
house
to rent in Caroline Place, Bayswater, W2 through Foxtons (Property to rent)
)
*/
正s
则表达式末尾的 将解析器放入(不恰当地)称为single-line mode
.