``` --- ##"> ``` --- ##" />
Easy Tutorial
❮ Func Xml Utf8 Decode Pdo Setattribute ❯

PHP define() Function

PHP Misc Reference Manual

Example

Defining a case-sensitive constant:

<?php
define("GREETING","Hello you! How are you today?");
echo constant("GREETING");
?>

Definition and Usage

The define() function defines a constant.

Constants are similar to variables, with the following differences:


Syntax

Parameter Description
name Required. Specifies the name of the constant.
value Required. Specifies the value of the constant. PHP7 supports arrays, as shown in the example: <?php<br>// PHP7+ support<br>define('ANIMALS', [<br> 'dog',<br> 'cat',<br> 'bird'<br>]);<br>echo ANIMALS[1]; // Outputs "cat"<br>?>
case_insensitive Optional. Specifies whether the constant name is case-insensitive. Possible values: TRUE - Case-insensitive<br>FALSE - Default. Case-sensitive

Technical Details

Return Value: Returns TRUE on success, FALSE on failure.
PHP Version: 4+
--- ---

More Examples

Example

Defining a case-insensitive constant:

<?php
define("GREETING","Hello you! How are you today?", TRUE);
echo constant("greeting");
?>

❮ Func Xml Utf8 Decode Pdo Setattribute ❯