Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
读取返回html的php文件_Php_Html - Fatal编程技术网

读取返回html的php文件

读取返回html的php文件,php,html,Php,Html,我尝试使用: file_get_contents("www.example.com/example.php"); 但它不起作用,我想这是因为它是一个php文件。如果它是“example.html”,它就可以工作。 我不想要php代码,它是后端,我知道这是不可能的。我想从“example.php”中得到的只是其中的html。因为布局是: <?php //php ?> <html> </html> 因此,尽管它是一个php文件,但有没有办法将其前端代码返回

我尝试使用:

file_get_contents("www.example.com/example.php");
但它不起作用,我想这是因为它是一个php文件。如果它是“example.html”,它就可以工作。 我不想要php代码,它是后端,我知道这是不可能的。我想从“example.php”中得到的只是其中的html。因为布局是:

<?php
//php
?>
<html>
</html>

因此,尽管它是一个php文件,但有没有办法将其前端代码返回到字符串中


谢谢。

您需要指定协议:

file_get_contents("http://www.example.com/example.php");

否则,它会认为它只是服务器上的一个文件名。

您需要指定协议:

file_get_contents("http://www.example.com/example.php");

否则,它会认为它只是服务器上的一个文件名。

如果您将一个web URL传递到
file\u get\u contents()
则基本上是对该URL发出一个正常的http请求,这意味着不可能恢复任何PHP,因为web服务器只向客户端发送HTML,而您向客户端请求页面内容

因此,如果您这样做(来源:PHP手册):

您将回显存储在
$homepage
中的URL的HTML(作为字符串)


您的错误是忘记包含协议(http或https)。

如果您将web URL传递给
文件\u get\u contents()
您基本上是在向该URL发出正常的http请求,这意味着不可能恢复任何PHP,因为web服务器只向客户端发送HTML,而您要求客户端提供页面内容

因此,如果您这样做(来源:PHP手册):

您将回显存储在
$homepage
中的URL的HTML(作为字符串)


您的错误是忘记了包含协议(http或https)。

怎么说它不起作用?PHP代码在发送到浏览器之前经过处理,因此所有输出都是HTML,因此应该可以正常工作。您可以使用cURL然后返回(echo)响应。如果它不起作用呢?PHP代码在发送到浏览器之前经过处理,因此所有输出都是HTML,因此应该可以正常工作