在我的PHP设置中,我将allow_url_include
设置为FALSE
,出于安全原因,我很乐意将其保持这种方式。
我想的时候
include 'https://example.com/path/to/include.php'; // <= THIS WON'T WORK
我可以使用:
include $_SERVER['DOCUMENT_ROOT'].'/path/to/include.php'; // <= BUT THIS WILL
到目前为止,很好。
但是现在,我正在尝试在运行时在PHP中创建然后include
虚拟文件的方法。
[我想知道PHP中是否有等同于javascript URL.createObjectURL()
的东西,此后我发现PHP可以读取data:
URI。
这听起来很有希望...但是因为我将allow_url_include
设置为FALSE
,PHP告诉我它无法include
以data:
开头的URI:
警告:通过
include(): data://
]在服务器配置中禁用了allow_url_include=0
包装器所以,而不是:
include 'data:application/x-php;base64,ZnVuY3Rpb24gdGVzdCgpe2VjaG8nVGhpcyB0ZXN0IGRhdGEgdXJsIGZ1bmN0aW9uIDEgaXMgd29ya2luZy4nO30gdGVzdCgpOw==';
我必须这样使用
file_get_contents
和eval
:
,但是,自然,除非绝对必要,否则我不想使用$Test_Function = file_get_contents('data:application/x-php;base64,ZnVuY3Rpb24gdGVzdCgpe2VjaG8nVGhpcyB0ZXN0IGRhdGEgdXJsIGZ1bmN0aW9uIDEgaXMgd29ya2luZy4nO30gdGVzdCgpOw=='); eval("$Test_Function");
后一种方法works
eval()
。有什么方法可以使PHP进入include
URI,[[无
data:
?注意:
您可能对我在这里使用base-64编码感到好奇:allow_url_include
仅是以下内容:
ZnVuY3Rpb24gdGVzdCgpe2VjaG8nVGhpcyB0ZXN0IGRhdGEgdXJsIGZ1bmN0aW9uIDEgaXMgd29ya2luZy4nO30gdGVzdCgpOw==
在我的PHP设置中,我将allow_url_include设置为FALSE,出于安全原因,我很乐意将其设置为FALSE。当我想包含'https://example.com/path/to/include.php'时; // <=这不会...
function test() {echo 'This test data url function 1 is working.';} test();
php://内存(data:
)。由于它的作用类似于常规文件,您可以在其中包含它吗?