开发者

DOMDocument : How to get data as string from oboject

开发者 https://www.devze.com 2023-03-28 21:40 出处:网络
i am using the following code : $doc = new DOMDocument(); $doc->loadHTML($url); $data = $doc->saveHTML();

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

精彩评论

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