Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Member Cranavvo's Avatar
    Join Date
    Sep 2013
    Location
    St. Helens, England
    Posts
    70
    Member #
    37189
    Liked
    11 times

    PHP Tutorial 2 - Variables


    This is a follow-up to my previous tutorial: PHP Tutorial 1 - Printing. It's wise you should read the last tutorial before you come onto the next one.

    Variables, like in all programming languages, is a value that can change constantly. Variables in PHP can be used everywhere and are very easy to define, for e.g.

    PHP Code:
    <?PHP
    $variable 
    "Connor Simpson"
    echo $variable;
    ?>

    Connor Simpson
    Variables can either be string(which is text) or integer(which is a numeric value). Text must be wrapped around quotation marks and numbers don't really have to, it helps that they're not.

    PHP Code:
    <?PHP
    $text 
    "This is a piece of text!<br />"
    $number 13;
    echo 
    $text;
    echo 
    $number;
    ?>

    This is a piece of text!
    13
    Variables can also be a boolean value (which means true or false). Boolean values, to take effect, must NOT be wrapped around quotation marks:

    PHP Code:
    <?PHP
    $thisistrue 
    true;
    $thisisfalse false;
    ?>
    Booleans can't be printed like normal variables since it's really just a pointer for PHP.

    Variables are key in PHP and most scripts you'll be making will use variables in some form. Thanks for reading.

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:49 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com