(PHP 4 >= 4.0.4, PHP 5, PHP 7)
constant — 锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷值
通锟斤拷 name
锟斤拷锟截筹拷锟斤拷锟斤拷值锟斤拷
锟斤拷锟姐不知锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷却锟斤拷要锟斤拷取锟斤拷锟斤拷锟斤拷值时锟斤拷constant() 锟酵猴拷锟斤拷锟斤拷锟剿★拷也锟斤拷锟角筹拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤,锟斤拷锟斤拷锟缴猴拷锟斤拷锟斤拷锟截筹拷锟斤拷锟斤拷锟斤拷
锟矫猴拷锟斤拷也锟斤拷锟斤拷 class constants锟斤拷
name
锟斤拷锟斤拷锟斤拷锟斤拷
锟斤拷锟截筹拷锟斤拷锟斤拷值锟斤拷锟斤拷锟斤拷锟斤拷锟轿达拷锟斤拷锟斤拷蚍祷锟� NULL
锟斤拷
锟斤拷锟斤拷锟斤拷锟轿达拷锟斤拷澹拷锟斤拷锟斤拷一锟斤拷 E_WARNING
锟斤拷锟斤拷拇锟斤拷锟�
Example #1 constant() 锟斤拷锟斤拷锟斤拷
<?php
define("MAXSIZE", 100);
echo MAXSIZE;
echo constant("MAXSIZE"); // same thing as the previous line
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!"
?>