isset()和empty()的区别

isset()检查变量是否定义,而empty()检查定义的变量是否是空值:

$g = array();
echo isset($g)?"isset(g) is true \n":"isset(g) is false \n";
echo empty($g)?"empty(g) is true \n":"empty(g) is false \n";

运行结果:

isset(g) is true //$g的值为非null
empty(g) is true //$g虽然已定义,但值为空

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.