(PHP)警告:file_get_contents()[function.file-get-contents]:无法解析主机名

时间:2016-06-03 20:36:07

标签: php html forms

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

  

警告: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/"));

?>

1 个答案:

答案 0 :(得分:1)

您使用的网址错误:

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

应该是:

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

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

相关问题