PHP中的Expressionengine标签 [英] Expressionengine tags inside php
问题描述
在启用了php解析的expressionengine中,
In expressionengine with php parse enabled,
如果我执行以下操作,则它可以正常工作,并且我会显示用户名.登录的用户是admin.因此,它回显了admin.
if i do the following, it works and i get the username displayed. logged in user is admin. So it echos out admin.
<?php
$x = '{username}';
echo $x;
?>
但是,如果我执行以下操作并使用{username}标签insde mkdir()
函数,则它将不起作用.创建的目录将具有名称{username}
而不是admin.为什么会这样.
However if i do the following and use the{username} tag insde mkdir()
function, then it doesn't work. The directory created will have the name {username}
instead of admin. Why is this happening.
<?php
$x = '{username}';
mkdir($x);
?>
推荐答案
我建议写一个快速的 plugin 接受登录的用户名作为参数,然后您的mkdir()
在插件中起作用.
I'd suggest writing a quick plugin that accepts the logged-in username as a parameter, then does your mkdir()
work within the plugin.
class Make_directory
{
var return_data = '';
function __construct()
{
$this->EE =& get_instance();
$username = $this->EE->TMPL->fetch_param('username', FALSE);
if($username != FALSE)
{
$dir = mkdir(escapeshellarg($username));
}
$this->return_data = $dir;
}
插件还有更多,但这就是它的胆量.然后像{exp:make_directory username="{logged_in_username}"}
这样称呼它.
There's more to the plugin, but that's the guts of it. Then call it like {exp:make_directory username="{logged_in_username}"}
.
这篇关于PHP中的Expressionengine标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!