05 - constants

Upload: sourabh-bhandari

Post on 07-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/4/2019 05 - Constants

    1/1

    unettuts, 2011 http://une

    PHP Constants

    A constant is a placeholder for the value that can be referenced in the code later.

    A constant can be created by using PHPs in-built function define() as:

    define(CONSTANT_NAME,value,boolean_value);

    The third Boolean argument can be used to determine whether constant name is

    case-sensitive or not. If boolean value is set to true, the constant name is case-

    insensitive. By default it is case-sensitive.

    Let us see a script below to demonstrate usage of constant:

    Above code snippet will output: Welcome sourabh. The period (.) is a used to

    concatenate text in php.

    Rules for naming constants:

    1. Constant names are typically named in capital letters (lowercase are also

    allowed).

    2. Constant name must begin with letter or underscore (_).

    3. It must not begin with number.

    Once a constant is defined, its value cannot be changed or altered.

    Check our more tutorials athttp://unettuts.com

    http://unettuts.com/http://unettuts.com/http://unettuts.com/http://unettuts.com/