PHP 定数の一覧取得(get_defined_constants())

あらかじめ設定されている定数や自分でdefine()した定数の一覧を取得したい

作成日:2018-06-12, 更新日:2018-06-12

基本

・get_defined_constants()で定数一覧取得
・「user」が自分で設定した定数

$constant = get_defined_constants(true);
var_export($constant['user']);