首頁  >  文章  >  後端開發  >  php中define()與defined()函數的使用詳解

php中define()與defined()函數的使用詳解

黄舟
黄舟原創
2017-11-15 11:00:412374瀏覽

在之前的文章中我們為大家介紹了php中define()的使用,以及php中define()與const的差別,今天為大家繼續介紹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參數nameRequired. 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

总结:

本文通过示例讲述了php中define()与defined()函数的使用详解,希望对你的工作上有所帮助!

相关推荐:

php常量define与const的区别详解


php中define的使用详解


php define常量定义与变量区别_PHP教程

# Description
描述

必要參數。指定常數的名稱

以上是php中define()與defined()函數的使用詳解的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn