深入了解 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]」;

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

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

留言

這個網誌中的熱門文章

c語言-關於#define用法

CMD常用網管指令

PHP 與 JavaScript 之間傳值利用 json