【问题标题】:Load page that will return that the address was not found. (basically load an non-loadable page)加载将返回地址未找到的页面。 (基本上加载一个不可加载的页面)
【发布时间】:2014-08-06 14:07:53
【问题描述】:

好吧,我的标题可能描述的不是特别多,但是,这是我的 PHP 代码:

<h1>404 Server Error</h1>
<?php
$ip = $_GET['ip'];
if($ip) {
$ip = str_replace('%3A', ':', $ip);
$ip = "http://" . $ip;
for($i = 0; $i < 11; $i++) {
$ch = curl_init($ip); // (Also tried file_get_contents($ip); instead, but didn't work
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 200);
curl_exec($ch);
curl_close($ch);
}
}
?>

我基本上希望它加载一个看起来像这样的页面: http://123.456.789:80/ (如果您访问实际站点,它将返回未找到服务器/站点) 但它仍然通过消息(我已经尝试过,所以我知道这一点)

无论如何,CURL 和 file_get_contents 都可以解决这个问题,因为他们期望得到一些回报,并且在他们尝试查找页面时会持续运行很长时间。但是我希望他们向页面发送请求,然后取消,我该怎么做?

TLDR:我想让 php 脚本发送请求/加载页面只需一毫秒/秒,即使它无法加载实际页面。

提前致谢。

TEMPSOLUTION:我使用&lt;iframe src='" . $ip . "'&gt;&lt;/iframe&gt; 作为临时解决方案。

【问题讨论】:

    标签: php curl file-get-contents


    【解决方案1】:

    使用 php 加载网站:

    header('Location: www.yourwebsite.com');
    

    【讨论】:

    • 我想在几秒钟内多次加载它,最好是。我做了一个临时解决方案,在 OP 中编辑它。
    猜你喜欢
    • 2012-12-20
    • 1970-01-01
    • 2014-04-20
    • 2014-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-10
    相关资源
    最近更新 更多