使用PHP将相对URL转换为绝对URL以获得完整网页

使用PHP将相对URL转换为绝对URL以获得完整网页,php,simplexml,Php,Simplexml,我正在使用PHP读取HTML文件: $w = file_get_contents('http://localhost/site1/theme/default/about.html'); PHP代码从http://localhost/site1/。我使用了simplexml来查找像images这样的东西,所以src=“images/image1.png”并将其更改为http://localhost/site1/theme/default/about/images/image1.png。 这是可行

我正在使用PHP读取HTML文件:

$w = file_get_contents('http://localhost/site1/theme/default/about.html');
PHP代码从
http://localhost/site1/
。我使用了
simplexml
来查找像images这样的东西,所以
src=“images/image1.png”
并将其更改为
http://localhost/site1/theme/default/about/images/image1.png
。 这是可行的,但我该如何改变

background-image: url("../images/World1.png");

到绝对路径?我查看了
url\u to\u absolute.php
,但没有找到它 做我需要的

href="../../stylesheet.css"