admin 管理员组

文章数量: 1184232


2023年12月17日发(作者:html制作音乐播放器代码)

difine()函数的作用,定义一个常量;

常量的特点

1、一个常量值在制定后就不可以被修改

2、设置常量是不需要在前面加$符号;

3、常量可以被所有范围域访问;

4、常量的值只能是字符串或者数字。

语法规则

define(name,value,case_insensitive)

参数说明:

Parameter

参数

name

value

Description

描述

Required. Specifies the name of the constant

必要参数。指定常量的名称

Required. Specifies the value of the constant

必要参数。指定常量的值

case_insensitive Optional. Specifies whether the constant name should be case-insensitive. If

set to TRUE, the constant will be case-insensitive. Default is FALSE (case-sensitive)

可选参数。指定常量的名称是否是不区分大小写的[case-insensitive]。如果设置为True,则不区分字母大小写;如果设置为False,则区分字母大小写。默认值是:False

eg:

constant("greeting");?>

上述代码将输出下面的结果:

复制代码代码如下:

Hello you! How are you today?

defined() 用于检测一个常量是否存在

语法

复制代码代码如下:

defined(name)

Parameter Description

参数 描述

name Required. Specifies the name of the constant to check

必要参数。指定常量对象的名称

Example

案例

复制代码代码如下:

you! How are you today?",TRUE);echo

defined("GREETING");?>


本文标签: 常量 代码 指定 参数 名称