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

WBOY
Release: 2016-06-13 13:02:05
Original
1187 people have browsed it

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

?

?

?

?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!