PHP Basics WorkshopDeveloped by: Paul Burney
VariablesTo declare a variable in PHP, just place a $ character before an alpha-numeric string, type an equals sign after it, and then a value.
The above code sets the variable $greeting to a value of "Hello World". We can now use that variable to replace text throughout the page, as in the example below:
The above code creates a page that prints the words "Hello World". One reason to use variables is that you can set up a page that repeats a value throughout and then only need to change the variable value to make all the values on the page change. In the next section, you will see how to put variables to work. |
|||||