Create + use constants in entire php program script inside function scope.
Constants are automatically build as globally so web developer doesn’t need to specify any extra keyword to make its constant as global constant. If developer can specify a constant at the top of php program then it can easily call inside below function scope. So here is the complete step by step tutorial for How to define global constant in php.
How to define global constant in php.
Code for Global_constant.php file.
<?php //Defining constant. define("NAME", "PHP & ANDROID TUTORIALS", true); //Defining function. function test() { //Printing constant value on screen using echo. echo NAME; } //Calling function. test(); ?>
Screenshot: