PHP eval()逻辑运算符错误 [英] PHP eval() logical operator error
问题描述
为什么
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将&&
转换为&&
.
Wordpress converts the &&
to &&
.
我以前遇到过这样的问题,所以很高兴知道.我在该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屋!