PHP eval()逻辑运算符错误 [英] PHP eval() logical operator error

查看:285
本文介绍了PHP eval()逻辑运算符错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么

if (isset($_SESSION['location']) AND !empty($_SESSION['location']))

边工作边

if (isset($_SESSION['location']) && !empty($_SESSION['location']))

不是吗?

我正在使用eval()在wordpress页面中处理PHP.对于我来说,为什么PHP在&&而不是AND上窒息是没有道理的.文档没有具体说什么,而且似乎没有其他人给出明确的答案.

I'm using eval() to process PHP in a wordpress page. It makes no sense to me why PHP chokes on && and not AND. The docs don't say anything specifically and no one else seems to have a clear answer.

感谢您的输入.

编辑

并不是真的很重要,但是我在WP模板中使用了eval():

Not that it really matters, but I use eval() in a WP template:

            $sContent   = get_the_content();
            $sContent   = apply_filters('the_content', $sContent);
            $sContent   = str_replace(']]>', ']]>', $sContent);

            eval(' ?>'. $sContent .'<?php ');

推荐答案

Wordpress将&&转换为&#038;&.

Wordpress converts the && to &#038;&.

我以前遇到过这样的问题,所以很高兴知道.我在该PHP WP模板中执行了大多数逻辑,所以只要我了解发生了什么,这没什么大不了的.

I've run into an issue like this before, so it's good to know. I do most of the logic in that PHP WP template, so this is no big deal, jsut as long as I understand what's going on.

感谢GigaWatt指出这一点,并让我想起了久违的记忆.

Thanks go to GigaWatt for pointing this out and reminding me of long lost memories.

这篇关于PHP eval()逻辑运算符错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆