PHP eval() logical operator error
Why does
if (isset($_SESSION['location']) AND !empty($_SESSION['location']))
work while
if (isset($_SESSION['location']) && !empty($_SESSION['location']))
does not?
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.
Thanks for your input.
EDIT
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(']]>', ']]>', $开发者_JAVA百科sContent);
eval(' ?>'. $sContent .'<?php ');
Wordpress converts the &&
to &&
.
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.
Thanks go to GigaWatt for pointing this out and reminding me of long lost memories.
精彩评论