Hướng dẫn define php
(PHP 4, PHP 5, PHP 7, PHP 8) define — Defines a named constant Descriptiondefine(string Parametersconstant_name The name of the constant.
value The value of the constant. In PHP 5, Warning While it is possible to define resource constants, it is not recommended and may cause unpredictable behavior. case_insensitive If set to Warning Defining case-insensitive constants is deprecated as of PHP 7.3.0. As of PHP 8.0.0, only
Return Values Returns Changelog
ExamplesExample #1 Defining Constants
define('ANIMALS', array( Example #2 Constants with Reserved Names This example illustrates the possibility to define a constant with the same name as a magic constant. Since the resulting behavior is obviously confusing, it is not recommended to do this in practise, though.
The above example will output: bool(false) bool(true) string(4) "test" int(5) See Also
ravenswd at gmail dot com ¶ 7 years ago
@SimoEast on Twitter ¶ 5 years ago
danbettles at yahoo dot co dot uk ¶ 13 years ago
Dale Landry ¶ 5 years ago
( "EXPLENATIVES", [1 => "Foo Bar", 2 => "Fehw Bahr", 3 => "Foo Bahr", 4 => "Fooh Bar", 5 => "Fooh Bhar", 6 => "Foo Barr", 7 => "Foogh Bar", 8 => "Fehw Barr", 9 => "Fu bar", 10 => "Foo Bahr", 11 => "Phoo Bar", 12 => "Foo Bawr", 13 => "Phooh Baughr", 14 => "Foogan Bargan", 15 => "Foo Bahre", 16 => "Fu Bahar", 17 => "Fugh Bar", 18 => "Phou Baughr"]);//set up define methods using mixed values; both array and non-array values eparkerii at carolina dot rr dot com ¶ 13 years ago
Jamie ¶ 11 years ago
chris at peeto dot net ¶ 12 years ago
("NEW_GOOD_NAME_CONSTANT", "I have a value"); me at mariusgerum dot de ¶ 3 years ago
swisschocolate at cmail dot nu ¶ 6 years ago
axew3 at axew3 dot com ¶ 6 years ago
Anonymous ¶ 5 years ago
define('const', 3); phen at adnerdum dot org ¶ 11 years ago
GOOD_OCTAL; jan at webfontein dot nl ¶ 14 years ago
constant("PAYMENT_$payparam");// output : David Spector ¶ 3 years ago
agneady at gmail dot nospam dot please dot com ¶ 11 months ago
ohcc at 163 dot com ¶ 2 years ago
|