PHP - define
Trieda
Metóda - define
(PHP 4, PHP 5, PHP 7)
The define() function is used to define a named constant during
runtime.
Note: We can use the defined() function to
determine whether a constant is defined.
Procedurálne
- function define (string $name, mixed $value, bool $case_insensitive = false) : bool
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $name | string | The name of the constant for usage in code. | |
| $value | mixed | The value of the constant. In PHP 5, the value must be scalar
( | |
| $case_insensitive | bool | false | If the value is Note: Case-insensitive constants are internally stored as lower-case. |
Mávratovej hodnoty
Vracia: bool
Returns true if the named constant has been defined
successfully, false otherwise.
Príklady
<?php
define('CONST_NUMBER', 1);
define('CONST_TEXT', 'Hello World!', true);
echo CONST_NUMBER; // prints 1
echo '<br>';
echo cOnST_NUmBER; // prints "cOnST_NUmBER" and a notice
echo '<br>';
echo CONST_TEXT; // prints "Hello World!"
echo '<br>';
echo cOnst_TEXT; // prints "Hello World!"
