
上QQ阅读APP看书,第一时间看更新
4.2 PHP变量函数库
除了用户自行编写的函数库外,PHP自身也提供了很多内置的函数,PHP变量函数库就是其中一个。但并不是所有的函数都会经常用到,如表4-1所示。
表4-1 常用的变量函数介绍表

isset()函数检查变量是否被设置,设置则返回TRUE,否则返回FALSE。其语法如下:

参数说明:var为必要参数,输入的变量。var2为可选参数,此参数是输入的变量,可有多个。
【例4-9】应用isset()函数和empty()函数判断用户提交的用户名和密码是否为空。

运行结果为:

isset()只能用于变量,因为传递任何其他参数都将造成解析错误。若想检测常量是否已设置,可使用defined()函数。