PHP Basics-PHP VARIABLES

Discussion in 'PHP/MySql' started by midlandi, Nov 18, 2007.

Remove these ads by signing in
Remove these ads by signing in
Thread Status:
Not open for further replies.
  1. midlandi Can you smell that?

    Member Since:
    Jan 22, 2007
    Message Count:
    4,758
    Likes Received:
    33
    Location:
    Uk
    Using variables in PHP is done in every single script, and is extremely basic PHP knowledge. If you have experience in any other programming languages, you'll know that all languages use variables. Variables are basically peices of code that hold information.

    I'll give you a basic, real life example of variable use. If you remember your mathematics class, you'll probably remember that in algebra, you used letters that would represent a number. For example, if I said "n = 1", then every time you seen the letter "n" in a mathematical equation, you'd see it as "1". This is a perfect example of how variables are seen by the PHP parser. Look at the example below.

    <?php

    $variable = "hello";

    ?>


    As you can imagine, the variable "$variable" is now going to be translated into "hello" by the PHP parser every time it is read. It's relatively simple. Notice how I used the PHP syntax (tags, semi-colons) in this as well. Remember, they are required! In the next tutorial ("PHP Echo"), we're going to learn how to put all this knowledge together and output things onto the screen with PHP using the echo() function.


    Next Step....
    PHP ECHO

    .
Thread Status:
Not open for further replies.

Share This Page