php变量与常量
之前,了解PHP的8个数据类型,继续. 常量英文字母、下划线、数字组成,单不能以数字开头 常量定义: define (string constant_name,mixed value,case_sensitive=true) constant_name:常量名 value:常量值 case_sensitive:可选参数,指定是否大小敏感,设定为true表示不敏感,默认值大小写敏感 获取常量值的2种方法: 1、使用常量名直接获取,2、使用constant()函数 两种方法效果一样,单constant()函数可以动态的输出不同的常量,使用上更灵活 格式为: mixed constant(string const_name) 参数const_name为要获取常量的名称,也可以为存储常量名的变量 判断常量是否已定义? bool defined(string const_name); 例子: define(“message”,”你看得到吗?”) echo message.” “; //输出常量message ecsho MESSAGE.”…