在 PHP 中包含一个远程文件

2022-01-25 00:00:00 include php

我无法在我的 PHP 脚本中包含远程 PHP 文件.我想我的主机更改了 php 设置.

我使用的代码是:

包括http://domain.com/folder/file.php";

如何允许使用 php.ini/.htaccess 启用包含功能?

还有其他解决方法吗?

谢谢.

解决方案

为了允许包含远程文件,指令 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)

相关文章