php include to external url

后端 未结 5 1387
迷失自我
迷失自我 2020-12-19 15:29

I am currently trying to use the php function \'include\' to include an external url. This is so that whenever the webpage is updated it will automatically update mine. The

5条回答
  •  别那么骄傲
    2020-12-19 15:51

    This will load an external website and also gives external links an absolute website link address

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://www.your_external_website.com");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = curl_exec($ch);
    curl_close($ch);
    $result = preg_replace("#(<\s*a\s+[^>]*href\s*=\s*[\"'])(?!http)([^\"'>]+)([\"'>]+)#",'$1http://www.your_external_website.com/$2$3', $result);
    echo $result
    

提交回复
热议问题