>  기사  >  백엔드 개발  >  php恒量 define() constant() , defined()

php恒量 define() constant() , defined()

WBOY
WBOY원래의
2016-06-13 13:02:051189검색

php常量 define() constant() , defined()

define――定义常量,若定义true,则读取时不区分大小写

bool define( string name, mixed value [, bool case_insensitive])

常量只能包含标量数据(booleanintegerfloatstring )。

define ( "CONSTANT" , "Hello world." );
echo
CONSTANT ; // outputs "Hello world."
echo Constant ; // outputs "Constant" and issues a notice.

define ( "GREETING" , "Hello you." , true );
echo
GREETING ; // outputs "Hello you."
echo Greeting ; // outputs "Hello you."

?

?

========================================

constant()――读取常量

mixed constant ( string name)

?

define ( "MAXSIZE" , 100 );

echo
MAXSIZE ;
echo
constant ( "MAXSIZE" ); // same thing as the previous line

?

===============================

?

defined――判断常量是否定义

?

bool defined ( string name)

?

if ( defined ( 'CONSTANT' )) {
????echo
CONSTANT ;
}

?

======================================================

?

预定义常量

?

__FILE__?? 取得文件的物理地址? 注:左右各2条下划线

?

echo __FILE__? ?? //C:\wamp\www\T1\1.php

?

?

?

?

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.