Stu*_*Stu 3 php stream include
我想知道是否可以创建一个流包装器,以便从数组中加载一些代码,使用类似下面的代码
<?php include 'template://myarraykey/'; ?>
Run Code Online (Sandbox Code Playgroud)
让它像从文件中进行正常包含一样工作吗?问的原因是因为我真的不想在文件系统上存储模板,它们要么存在于memcache中,要么存在于数据库表中,并且不想使用eval().
另外我会假设我需要将allow_url_include设置为on?
我知道这是一个老问题...但我认为值得注意的是你可以做一些事情:
$content = '
<?php if($var=true): ?>
print this html
<?php endif; ?>
';
Run Code Online (Sandbox Code Playgroud)
通常这对eval来说非常麻烦,但你可以这样做:
include "data://text/plain;base64,".base64_encode($content);
Run Code Online (Sandbox Code Playgroud)
它会像它一样解析它!