PHP Variables


PHP is similar to ASP and other programming languages in that it allows you create variable to store values. PHP has serveral variable types with the most commonly used of these being the STRING variable.

In PHP all strings begin with a $ statement. For example

<?php
	$address = "Kingswoods Heights, California";
?>


Here we have created a variable called $address and assigned it the value Kingswoods Heights, California. As you can see everything inside the quotation marks will be assigned to the string $address.

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_address Variables with more than one word can also be distinguished with capitalization. $myAddress


php variables tutorials