PHP Beginners Tutorial Lesson 1 - Your First Code
Open up notepad and write the following text into it.
echo 'This is a PHP script';
Save the file as test.php making sure you change the ‘save as type’ bit in notepad to all files. If you don’t do this it can stick a .txt on the end of your file and it wont work.
If you are working on an internet based server, use FTP to upload your file there.
Open your web browser and point it at the root of your home directory. In my case I am using my web server which is at Sloomedia.com. To access the script I put in http://www.sloomedia.com/test.php and up pops the result.
Some things to point out about the script.
- In order to move from the HTML page to the PHP you have to open with a..
and close with a
Every line of code within the PHP tags needs to be closed with a ; character. If this doesn't happen PHP will carry on reading the script until it finds a suitable or unsuitable closing character.
Click here to download a zip file with some example PHP scripts in it.
Lesson 2 - Using Variables - Click here to continue.