PHP code for constant

PHP code for constant - constant can be defined by const keyword and define method

Example :


<?php
define("CONSTNAME", "Learn PHP constant");
echo CONSTNAME;
?>

<?php
const VARNAME = "Learn PHP constant";
echo CONSTNAME;
?>


<?php
define("SHORTDESC", "Welcome to aryatechno tutorials!");
function checkScope() {
echo SHORTDESC;
}
checkScope();
?>

Output :

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

72961