我的页面中有以下图片 src
<img src="http://path_to_image/platinum/getmedia?ID=97629047310&LOOT=50041223935" width="290" height="193">
和我的php中的这段代码
$dom = new DOMDocument();
$dom->loadHTML($page);
foreach ($dom->getElementsByTagName('img') as $img) {
$src = $img->attributes->getNamedItem('src')->nodeValue;
if ($src{0} === '/') {
$src = 'http://' . $server . $src;
}
$img->attributes->getNamedItem('src')->nodeValue = $src;
}
$page = $dom->saveHTML();
如果我在 saveHTML 之后查看 $page ,则 img src 是
<img src="http://path_to_image/platinum/getmedia?ID=97629047310" width="290" height="193">