• Saturday, February 8, 2014

    Learn PHP - Variables

    Variables are those words whose value varies and use to store constants like 5,6,"hello" etc..

    In PHP variabes are declared by $(dollar sign).

    Syntax: $variable_name

    Variable may be anytype. There is no need to define variable for any data type, PHP auto define it when the first value passes to variable.

    Example:

    $x = 5; //Integer type variable

    $m = "hello"; //string type variable

    $x = 5;
    $y = 8.5; // float type variable.
    $z = $x + $y; //float type variable.
    echo $z;
    //Output: 13.5

    Rules for defining variables:
    * Variable start with alphabets.
    * It can be alphanumeric with special symbol _ .

    Syed Masoom Rizvi

    Author & Editor

    Hi, This is Syed Masoom Rizvi, who is continue exploring the world of programming ,programming and programming... :)

    0 comments:

    Post a Comment