PHP String Variable

Created by Phil Thompson

A PHP string variable is a way to store information in a PHP script and allows you to ask for the information at any time you want very easily.   A string variable in PHP always starts with a $ sign and is then given a name:


  To set a value to it is very simple. Lets give $name a value of John this is how you will do it:

$name = 'John';

As with all PHP you must declair the end of the line with a ;   Now to call that stored information and display it all you need to do is use the PHP function echo just like bellow:

$name = 'John';

echo $name;

This will now display on your page:   John   And that is a PHP String Variable.   Just remember to give it a name plus give it content to remember and this can be a very powerful and useful tool.
comments powered by Disqus