Home arrow PHP Tutorials

Translate This Website
Saturday, 22 November 2008
Web Development
Request a Quote
Script Categories
RSS Media Grabber Funny Videos & Pictures Life Stories (Flash) Video Search & Download Video Downloader Script Country on Sale Advanced Polls Phone Upload/SMS Scripts PhotoCube Script SlideShow Creation Script Create Custom Smiley Script Short URLs & Subdomains Put your text on images Watermark & Image Hosting Joomla Components Low Cost Scripts
Partners
WEBSITE TRAFFIC
Credit Cards
Online HTML Editor
Wordpress Themes
Custom Programming
Scripts and Stuffs
Hot php scripts
Add your scripts
Script Search
php scripts directory
script heaven
the cgi site
Scripts
Software Development
Free Icons
SEO Services


PHP Variables Print E-mail

PHP Variables

All variables in PHP start with a $ sign symbol. Variables may contain strings, numbers, or arrays.

Variables are used for storing values, such as numbers, strings or function results, so that they can be used many times in a script.  A variable is a means of storing a value, such as text string "Hello World!" or the integer value 4. A variable can then be reused throughout your code, instead of having to type out the actual value over and over again.
In PHP you define a variable with the following form:

$variable_name = Value;

A Quick Variable Example

Say that we wanted to store the values that we talked about in the above paragraph. How would we go about doing this? We would first want to make a variable name and then set that equal to the value we want. See our example below for the correct way to do this.

PHP Code:

<?php
$hello = "Hello World!";
$a_number = 4;
$anotherNumber = 8;
?>

Note for programmers: PHP does not require variables to be declared before being initialized.

PHP Variable Naming Conventions

There are a few rules that you need to follow when choosing a name for your PHP variables.

  • PHP variables must start with a letter or underscore "_".

  • PHP variables may only be comprised of alpha-numeric characters and underscores. a-z, A-Z, 0-9, or _ .

  • Variables with more than one word should be separated with underscores. $my_variable

  • Variables with more than one word can also be distinguished with capitalization. $myVariable

 

 

 

 

Credits: www.tizag.com

 





Reddit!Del.icio.us!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites!
 
< Prev   Next >
Services
Script Installation
Hosting
Free Image Hosting
PageRank Checker
Login Form
On Sale
RSS Media Grabber - Get 100s of Videos
RSS Media Grabber - Get 100s of Videos
$129.00
$79.00
You Save: $50.00
Add to Cart
Home Announcements Support Newsletter Forum PHP Articles PHP Tutorials Scripts FAQs Free Scripts Links Contacts
Copyrighted © 2008 phppod.com