Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • The difference between constant and variable

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 48
    Comment on it

    In php we have both constant and variable

    A constant is a name for a value which can not be changed during the execution of the script.

    It start with a letter or a underscore.

    It start with constantname().

     

    The differences-

    There is no need to write the $ sign with a constant where as with a variable you have to write it as $name.

    Constant can not be declared directly they can only be declared under the define().

    They can be defined and can be accessed anywhere.

    Once set it can not be undefined or redefined.

     

    Constant name-

    valid constant names define("ONE", "first thing");

    define("TWO2", "second thing");

    define("THREE_3", "third thing")

     

    Variable name-

    $name.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: