如何在PHP中包含外部文件? [英] How do I include an external file in PHP?

查看:129
本文介绍了如何在PHP中包含外部文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要包含另一个网址上的外部文件。例如google.com。我已经测试了包含使用本地文件,所以很多作品,但如果我尝试使用127.0.0.1/filetoinclude.txt没有任何反应。我没有收到错误,我只是得到一个空白页面。
那么,我应该如何在自己的网页中添加 http://google.com

I need to include and external file that is on another url. For example google.com. I have tested the include using local files, so that much works, but if I try and use 127.0.0.1/filetoinclude.txt Nothing happens. I don't get an error, I just get a blank page. So how am I supposed to include http://google.com in my page?

推荐答案

我不知道为什么你想这样做,但你肯定可以尝试这样的:

I have no idea why you'd want to do this, but you could most certainly try something like:

<?php
    $google_page = file_get_contents('http://www.google.com');
    echo $google_page;
?>

这篇关于如何在PHP中包含外部文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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