一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - PHP教程 - 深入php define()函數以及defined()函數的用法詳解

深入php define()函數以及defined()函數的用法詳解

2020-04-03 15:13PHP教程網 PHP教程

本篇文章是對php中的define()函數以及defined()函數的用法進行了詳細的分析介紹,需要的朋友參考下

The define() function defines a constant.
define()函數的作用是:定義一個常量。
Constants are much like variables, except for the following differences:
常量[constant]與變量[variable]有很多相似的地方,因此,很容易混淆;下面,我們列舉一下常量[constant]與變量[variable]之間的不同點:

•A constant's value cannot be changed after it is set
一個常量值在指定之后就不可以更改;
•Constant names do not need a leading dollar sign ($)
設置常量時,不需要在前面加上“$”符號;
•Constants can be accessed regardless of scope
常量可以被所有范圍的域訪問;
•Constant values can only be strings and numbers
常量的值只能是“字符串[string]”和“數字[number]”;

Syntax
語法

復制代碼 代碼如下:

define(name,value,case_insensitive)

 

Parameter
參數

Description
描述

name

Required. Specifies the name of the constant
必要參數。指定常量的名稱

value

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

 

 

Example 1
案例1

Define a case-sensitive constant:
指定一個常量(區分大小寫):

復制代碼 代碼如下:

<?phpdefine("GREETING","Hello you! How are you today?");echo constant("GREETING");?>


The output of the code above will be:
上述代碼將輸出下面的結果:

復制代碼 代碼如下:

Hello you! How are you today?


Example 2
案例2

Define a case-insensitive constant:
指定一個常量(不區分大小寫):

復制代碼 代碼如下:

<?phpdefine("GREETING","Hello you! How are you today?",TRUE);echo constant("greeting");?>


The output of the code above will be:
上述代碼將輸出下面的結果:

復制代碼 代碼如下:

Hello you! How are you today?


The defined() function checks whether a constant exists.
defined()函數的作用是:檢查一個常量是否存在。

 

Returns TRUE if the constant exists, or FALSE otherwise.
如果該常量存在,則返回True;如果不存在,則返回False。

Syntax
語法

復制代碼 代碼如下:

defined(name)

 

Parameter
參數

Description
描述

name

Required. Specifies the name of the constant to check
必要參數。指定常量對象的名稱

 

Example
案例

復制代碼 代碼如下:

<?phpdefine("GREETING","Hello you! How are you today?");echo defined("GREETING");?> 


The output of the code above will be:
上述代碼將輸出下面的結果:

復制代碼 代碼如下:

1

 

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 四虎影院在线免费观看 | 亚洲精品国产综合久久一线 | 欧美日韩中文字幕在线视频 | free chinese麻豆 | 国产亚洲精品高清在线 | 亚洲精品国产国语 | 日本老妇乱子伦中文视频 | 国产精品久久国产精品99 gif | 韩剧消失的眼角膜免费完整版 | 国产自产自拍 | 亚洲欧美日韩国产精品影院 | 久久精品亚洲精品国产欧美 | 国产一级毛片外aaaa | 欧美se图 | 四虎国产| 亚洲无限观看 | 女人扒开下面让男人桶爽视频 | 日韩毛片在线 | 色综合天天网 | 日本视频二区 | 国产午夜精品久久久久小说 | 日本三不卡| 国产尤物精品视频 | 日日艹| 4438成人网 | 精品一区二区三区免费毛片 | 国产精品久久99 | 白丝校花被扒开双腿喷水小说 | 欧美猛男同志video在线 | 午夜伦伦电影理论片大片 | 免费精品在线 | 狠狠干快播 | 草莓视频网站18勿进 | 激情视频亚洲 | 亚洲风情无码免费视频 | 91人人在线| 国产精品国产色综合色 | 亚洲精品午夜级久久久久 | 高h辣文小说网 烧书阁 | 美女视频久久 | 欧洲美女啪啪 |