* Archive for Apr, 2008 *

05
Apr
2008

比较和逻辑运算符

             符    号

        含    义

             类    型

      示    例

= =

等于

比较

$x == $y

!=

不等于

比较

$x != $y

小于

比较

$x < $y

大于

比较

$x > $y

<=

小于或等于

比较

$x <= $y

>=

大于或等于

比较

$x >= $y

!

逻辑

!$x

&&

逻辑

$x && $y

||

逻辑

$x || $y

XOR

异或

逻辑

$x XOR $y

Read the rest of this entry »

01
Apr
2008

Finally, I’ve fixed the problem of language recognition.

Before, my site can not filter the posts very well in a language which is determined by the browser’s language setting to show on the homepage.
When I use the code :
<?php if ($_SERVER["HTTP_ACCEPT_LANGUAGE"] != “zh-CN”) {query_posts(’cat=57,16′);} ?>
in homepage, the posts can be filtered correctly in IE7: If your browser’s language setting is zh-CN, the homepage will show all the posts, else, the homepage will show all the posts in category ID 57/16.
But in IE6 or FireFox, it doesn’t work. Because the browser’s language setting is “zh-cn”, it’s not “zh-CN”.

So I added a condition :
<?php
            $lan=&$_SERVER["HTTP_ACCEPT_LANGUAGE"];
            if (($lan != “zh-CN”)&&($lan != “zh-cn”)) {query_posts(’cat=57,16′);}
?>

Maybe it is not very “beautiful”, but it works very well for me! So hope it can help you! Maybe one day, I can make it smarter!

Ps: The codition part is a general format in PHP code, but the execute part is only for Wordpress!