例1,检查PHP的全局身份验证变量
例2,isset()检查一个变量是否设置值
<?
$foo = 1;
if (isset($foo)) {
echo "Foo is setn";
} else {
echo "Foo is not setn";
}
if (isset($bar)) {
echo "Bar is setn";
} else {
echo "Bar is not setn";
}
?>
例3,查看用户cookie,学习下isset()的用法
<?php
setcookie("username","michele");
echo 'Cookie created.';
if (!isset($_COOKIE['username'])){
echo ("Oops, the cookie isn't set!");
}else{
echo ("The stored username is ". $_COOKIE['username'] . ".");
}
?>
例4,isset()函数查看数组元素是否定义
您可能感兴趣的文章:
PHP 函数 isset、array_key_exists 的差异