在我使用的插件中:
$this->return_data = json_encode(array('loggedin' => $LoggedIn, 'Cust_ID' => $Participant_ID));在模板中,我这样调用它
$custinfo = {exp:user_loggedin};它以如下方式返回它:
$custinfo = {"loggedin":"no","Cust_ID":-1};我得到了这个错误:
PHP Parse error: syntax error, unexpected '{' in expressionengine/libraries/Functions.php(642) : eval()'d code on line 656如果我使用
$custinfo = json_decode({exp:user_loggedin})我得到了这个错误:
PHP Parse error: syntax error, unexpected '{', expecting ')' in expressionengine/libraries/Functions.php(642) : eval()'d code on line 656有什么想法吗?
发布于 2012-07-24 00:30:04
我猜你需要引用你的变量:
$custinfo = "{exp:user_loggedin}";
发布于 2012-07-24 03:50:55
我认为你有一个解析顺序问题和引用问题的组合。
假设您正在处理输出上的PHP。
Derek,认识到引用问题,建议:
$custinfo = "{exp:user_loggedin}";但是,在阶段3中,这不会转换为以下代码吗?
$custinfo = "{"loggedin":"no","Cust_ID":-1}";这看起来像是有效的PHP代码吗?对我来说不是。
您要么必须转义这些引号,要么使用HEREDOC或其他…
$custinfo = <<<HEREDOC
{"loggedin":"no","Cust_ID":-1}
HEREDOC;https://stackoverflow.com/questions/11615720
复制相似问题