开发者

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 &#038;&.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜