|
php define and constant
|
|
|
define(name, value, case-insensitive)
|
|
|
if we not given third value, it wil take it as case sensitive
(false)
|
|
|
case sensitive means there is a difference between capital and
small
|
|
|
<?php
|
|
|
define("MESSAGE","Hello JavaTpoint PHP");
|
|
|
echo MESSAGE;
|
|
|
?>
|
|
|
prints
|
|
|
Hello JavaTpoint
|
|
|
echo message;
|
no data
|
|
<?php
|
|
|
define("MESSAGE","Hello JavaTpoint PHP,true");
|
|
|
echo MESSAGE;
|
|
|
?>
|
|
|
echo MESSAGE;
|
Hello JavaTpoint PHP
|
|
echo message;
|
Hello JavaTpoint PHP
|
|
<?php
|
|
|
const MESSAGE="Hello const by JavaTpoint PHP";
|
|
|
echo MESSAGE;
|
|
|
?>
|
|
|
echo MESSAGE;
|
Hello JavaTpoint PHP
|
|
echo message;
|
message
|
|
<?php
|
|
|
define("MSG", "JavaTpoint");
|
|
|
echo MSG, "</br>";
|
JavaTpoint
|
|
echo constant("MSG");
|
JavaTpoint
|
|
//both are similar
|
|
|
?>
|
|
|
echo constant("msg");
|
no output
|
|
same variable we can define number of times, but constant cannot
redefined, once defined its over, that ist time value only displays if we
define using constant
|
|
Tuesday, 16 June 2020
php constant and define
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment