define

(PHP 4, PHP 5, PHP 7)

define — ����һ������

˵��

define ( string $name , mixed $value [, bool $case_insensitive = false ] ) : bool

������ʱ����һ��������

����

name

��������

value

������ֵ���� PHP 5 �У�value �����DZ���( integer�� float��string��boolean��NULL���� PHP 7 �л������Ǹ� array ��ֵ��

Warning

���������Զ���Ϊ resource ���ͣ��������Ƽ�����������Ϊ���ܻ��в���Ԥ֪����Ϊ������

case_insensitive

�������Ϊ TRUE���ó������Сд�����С�Ĭ���Ǵ�Сд���еġ����磬 CONSTANT �� Constant �����˲�ͬ��ֵ��

Note:

��Сд�����еij�����Сд�ķ�ʽ���档

����ֵ

�ɹ�ʱ���� TRUE�� ������ʧ��ʱ���� FALSE��

������־

�汾 ˵��
7.0.0 ���� array ��ֵ��

����

Example #1 ���峣��

<?php
define
("CONSTANT", "Hello world.");
echo 
CONSTANT; // ��� "Hello world."
echo Constant; // ��� "Constant" ������ Notice

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

//  PHP 7 ��Ϳ���������
define('ANIMALS', array(
    
'dog',
    
'cat',
    
'bird'
));
echo 
ANIMALS[1]; // ��� "cat"

?>

�μ�

  • defined() - ���ij�����Ƶij����Ƿ����
  • constant() - ����һ��������ֵ
  • Constants��һ��