rurtubia
11/17/2015 - 12:24 AM

PHP Constants

PHP Constants

<?php

//Declaring a constant.
    //Constants do not start with a "$" sign.
    //They need to be declared by using the function "define()"
    //define() syntax:
      #name: name for the constant.
      #value: value for the constant.
      #case-insensitive: default is false.
        
        //case sensitive constant:
        define(numero_dos, 2);
        
        //case insensitive constant:
        define(numero_cero, 0, true);
        
        //All constants are global:
        //They can be used across the entire script:
        
        define(saludo, "Hello World");
        
        function myFuncion(){
            echo saludo;
        }
        
?>