[Part 4] Variables

Iamcoolz Feb 18, 2015

  1. Iamcoolz

    Iamcoolz Forum Administrator Staff Member XPG Administrator
    205/282

    Joined:
    Mar 30, 2012
    Messages:
    1,227
    Likes Received:
    507
    Trophy Points:
    205
    Gender:
    Male
    Location:
    XPG
    Console:
    Xbox One
    Variables are code you assign your own rules too. Luckily with PHP there aren't a lot of rules or things you can't do with variables.

    Things to know:
    Variables with PHP are almost similar to Perl coding.
    PHP automatically converts certain types from one to another.
    Variables are wrote with a $ sign in-front of them, this keeps it cleaner in your code.

    Data Types:
    • Booleans - Only two possible values, true or false.
    • Strings - Sequence of characters.
    • Arrays - Named collections of other values.
    • Doubles - Floating numbers such as 9.9 and so on.
    • Integers - Whole numbers, no decimal point, like 9999.
    • Objects - These programmer defined classes, and can combine to make one class.
    • Resources - Special variables that hold external resources to PHP, (Database Connections)

    Examples:

    Boolean:

    if (true)
    print ("I am a winner");
    else
    print("I am a loser");
    Integers:

    $integer = 9999;
    $integer2 = 9998;

    Doubles:

    $doubles = 3.14
    $doubles2 = 3.17
    Strings:

    $string1 = "XPGamesaves for life";
    $string2 = "Bullet is the Founder";
    $string3 = "DS is a noob";

    -Iamcoolz
     

Share This Page

Close