包含文件的全部内容并回显 [英] Include whole content of a file and echo it

查看:77
本文介绍了包含文件的全部内容并回显的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要回显包含文件的全部内容.我尝试了以下方法:

I need to echo entire content of included file. I have tried the below:

echo "<?php include ('http://www.example.com/script.php'); ?>";

echo "include (\"http://www.example.com/script.php\");";

但是都行不通吗? PHP支持吗?

But neither works? Does PHP support this?

推荐答案

只需:

include("http://www.mysite.com/script.php");

或者:

echo file_get_contents("http://www.mysite.com/script.php");

注意:

  • 由于网络延迟或另一台服务器运行缓慢,这可能会使您的页面速度变慢.
  • 这要求您安装PHP时必须打开allow_url_fopen.一些主机将其关闭.
  • 这不会为您提供PHP代码,而会为您提供HTML/文本输出.
  • This may slow down your page due to network latency or if the other server is slow.
  • This requires allow_url_fopen to be on for your PHP installation. Some hosts turn it off.
  • This will not give you the PHP code, it'll give you the HTML/text output.

这篇关于包含文件的全部内容并回显的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆