How do I include an external file in PHP?(如何在 PHP 中包含外部文件?)
问题描述
我需要包含另一个 url 上的外部文件.例如 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 中包含外部文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 PHP 中包含外部文件?


基础教程推荐
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01