logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
Action Movies
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel
Southwest USA


dailyclick
All times in EST

Full Schedule
g
g PHP Site

BellaOnline's PHP Editor

g

More About PHP Variables

Guest Author - Diane Cipollo

When it comes to working with variables in PHP there are a few basics that you should keep fresh in your mind. Here we will discuss the types of PHP variables and a few rules you need to follow when naming your variables.

Naming Variables

  • The first rule is that variables begin with a dollar sign placed in front of the name of your variables. The dollar sign tells the server to treat this piece of code as a variable.

    $title_of_tutorial

  • The next rule is that the first character in the name of your variable must be a letter or an underscore. Although you can use numbers, letters and the underscore character _ when creating names for your variables, the first character in the name must be a letter or an underscore. A variable name can be any length.

    $tutorial_no2

  • The third rule is that variable names are case sensitive. That means that uppercase letters are considered different from lowercase letters. For example the variable name of Cat is not the same as the variable name cat. These two variable names are considered two different names.

    $Cat
    $cat

Types of Variables

  • There are two types of PHP variables. The first is a scalar variable. A scalar variable is a "simple" variable because it only contains one value. For example the variable $title_of_tutorial might be assigned the value of "More About PHP Variables".

    $title_of_tutorial = "More About PHP Variables";

  • The second type of variable is an array and it is a little more complicated. An array contains a list of values or another array. You can think of an array much like a tree. Each branch of the tree is a different value for the whole tree.

    $tree[0] = "first value";
    $tree[1] = "second value";
    $tree[2] = "third value";




This site needs an editor - click to learn more!

Add More+About+PHP+Variables to Twitter Add More+About+PHP+Variables to Facebook Add More+About+PHP+Variables to MySpace Add More+About+PHP+Variables to Del.icio.us Digg More+About+PHP+Variables Add More+About+PHP+Variables to Yahoo My Web Add More+About+PHP+Variables to Google Bookmarks Add More+About+PHP+Variables to Stumbleupon Add More+About+PHP+Variables to Reddit




RSS | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the PHP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2014 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

g


g features
Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor