Lesson 1 - Your First PHP Code

PHP Beginners Tutorial Lesson 1 - Your First Code


Open up notepad and write the following text into it.

<?php
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. 

Basic PHP script

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..

<?php
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.



 HOME
 THE COMPANY
 WEB MARKETING
 DESIGN AGENCY
 TESTIMONIALS
 TUTORIALS
1 - YOUR FIRST PHP CODE
2 - USING VARIABLES
PHP POSTCODE SCRIPT
Distance Between Postcodes
Pixelotto
 CONTACT
 WEB DESIGN LINK EXCHANGE

©Sloomedia 2004, Web Site Design Nottingham, UK - email:info@sloomedia.com