【问题标题】:(PHP) Warning: file_get_contents() [function.file-get-contents]: couldn't resolve host name(PHP) 警告:file_get_contents() [function.file-get-contents]:无法解析主机名
【发布时间】:2016-06-03 20:36:07
【问题描述】:

我需要一些帮助来修复我的代码。我环顾四周,无法让它工作。以下是我收到的错误消息:

警告:file_get_contents() [function.file-get-contents]:无法解析第 13 行 /home/a9317671/public_html/prox/get.php 中的主机名

警告:file_get_contents(http://http://ben-nottelling.comlu.com/) [function.file-get-contents]:无法打开流:第 13 行 /home/a9317671/public_html/prox/get.php 中的操作失败

我的代码:

<!DOCTYPE html>
<html>
<body>

<form name='form' method='post' action="get.php">

ULR (no https/https): <input type="text" name="name" id="name" ><br/>

<input type="submit" name="submit" value="Submit">

</body>
</html>

还有get.php 代码(这是出现问题的地方):

<?php

$length = 10;

$fname= substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);


$name = $_GET['name'];
echo $name;

echo "The is a test. File will be at: http://ben-nottelling.comlu.com/prox/$fname.html";

file_put_contents($fname.html, file_get_contents("http://http://ben-nottelling.comlu.com/"));

?>

【问题讨论】:

  • 你在字符串中加倍了http://协议。
  • 我将此标记为“一个简单的印刷错误”,因为主机是作为文字传递的,并且该修复程序不太可能在将来帮助任何人。

标签: php html forms


【解决方案1】:

你使用的网址有误:

http://http://ben-nottelling.comlu.com/

应该是:

http://ben-nottelling.comlu.com/

下次调试类似的东西。尝试查看这段代码在做什么并手动尝试一下,因此在这种情况下,只需在浏览器中访问此 url 即可获得一些信息。

【讨论】:

    猜你喜欢
    • 2012-07-07
    • 2012-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多