php原生代码安全吗,是否允许树枝模板访问任何原生PHP函数比普通的旧PHP安全性要低得多?...

我正在研究Twig Engine plugin for Wordpress。

这个想法是让设计师在创建WordPress主题的同时使用Twig。

不过,Wordpress基本上是建立在全局和全局函数之上的,而小枝约定是建立在OOP之上的。

我试图保持尽可能接近普通的旧php php wording的implimation。

Twig Recipe显示模板如何访问全局函数:

index.php文件:

$loader = new Twig_Loader_Filesystem(dirname(__FILE__));

$twig = new Twig_Environment($loader, array('cache' => false));

// ### ! begin Recipe from Twig Docs:

// auto-register all native PHP functions as Twig functions

// don't try this at home as it's not secure at all!

$twig->registerUndefinedFunctionCallback(function ($name) {

if (function_exists($name)) {

return new Twig_Function_Function($name);

}

return false;

});

// ### ! end recipe

$template = $twig->loadTemplate('index.html.twig');

$template->display(array('posts' => $posts));index.html.twig:

{# Twig flavored The Loop #}

{% if have_posts() %}

{# This is a hacked wordpress loop - its modified to work with a for loop #}

{% for post in posts %}

{{ the_post() }}

{{ the_title() }}

{{ the_content() }}

{% endfor %}

{% endif %}我的问题:是否允许树枝模板访问任何原生PHP函数比普通的旧PHP安全性要差得多?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值