开发者

DOMDocument : How to get data as string from oboject

i am using the following code :

$doc = new DOMDocument();
$doc->loadHTML($url);
$data = $doc->saveHTML();
preg_match_all("/$k1(.*?)$k2/s",$data,$matches);

and it's generating this error :

Warning开发者_JS百科: preg_match_all() expects parameter 2 to be string, object given in /home/maruf10/public_html/dispatx.php on line 115

it will be helpful if anyone help to find the bug . thanks


change

$data = $doc->saveHTML();

into

$data = (string)$doc->saveHTML();

it should work then.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜