Some practice with variables
First, we’ll take a look at how to display what’s in your variables. We’re going to be viewing our results on a web page. So see if you can get this script working first because it’s the one we’ll be building on. Using a text editor like Notepad, or your PHP software, type the following. (You can copy and paste it if you prefer. But you learn more by typing it out yourself – it doesn’t sink in unless you’re making mistakes!)
When you’ve finished typing it all, save the page as practice.php. Then Run the script. Remember: when you’re saving your work, save it to the WWW folder.
To run the page, start your browser up and type this in the address bar:
If you’ve created a folder inside the www folder, then the address to type in your browser would be something like:
Add the following lines in your code:
We’ve set up a variable called $test_String. After the equals sign, the text “It Worked!” has been added. The line is then ended with a semi-colon. Don’t run your script yet. Change the Print line to this: