男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站

constant

(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)

constant返回一個(gè)常量的值

說(shuō)明

constant(string $name): mixed

返回 name 對應的常量的值。

當你不知道常量名,卻需要獲取常量的值時(shí),constant() 就很有用了。也就是說(shuō),常量名儲存在一個(gè)變量里,或者由函數返回時(shí)。

該函數也適用 類(lèi)常量。

參數

name

常量名。

返回值

返回常量的值。如果常量未定義則返回 null 。

錯誤/異常

如果常量未定義,會(huì )產(chǎn)生一個(gè) E_WARNING 級別的錯誤。

范例

示例 #1 constant() 的例子

<?php

define
("MAXSIZE"100);

echo 
MAXSIZE;
echo 
constant("MAXSIZE"); // 和上行一樣


interface bar {
    const 
test 'foobar!';
}

class 
foo {
    const 
test 'foobar!';
}

$const 'test';

var_dump(constant('bar::'$const)); // string(7) "foobar!"
var_dump(constant('foo::'$const)); // string(7) "foobar!"

?>

參見(jiàn)

  • define() - 定義一個(gè)常量
  • defined() - 檢查某個(gè)名稱(chēng)的常量是否存在
  • 關(guān)于 常量 的章節

男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站