且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 PHP 中包含一个远程文件

更新时间:2023-11-24 09:35:34

为了允许包含远程文件,指令 allow_url_include 必须在 php.ini 中设置为 Onp>

但从面向安全的角度来看,这很糟糕;因此,它通常被禁用(实际上我从未见过它启用)

allow_url_fopen,它处理打开(不包括)远程文件——这个通常是启用的,因为它使通过 HTTP 获取数据更容易(比使用 curl 更容易)

I am unable to include a remote PHP file in my PHP script. I suppose my hosting changed php settings.

The code I was using was:

include "http://domain.com/folder/file.php";

How do I allow enable the include function using php.ini/.htaccess ?

Is there any other workaround?

Thanks.

To allow inclusion of remote files, the directive allow_url_include must be set to On in php.ini

But it is bad, in a security-oriented point of view ; and, so, it is generally disabled (I've never seen it enabled, actually)

It is not the same as allow_url_fopen, which deals with opening (and not including) remote files -- and this one is generally enabled, because it makes fetching of data through HTTP much easier (easier than using curl)