Welcome to PHP training
1. Get yourself an editor - one that promises it'll make it easy for you to code in PHP. The main beneifit I find is they 'highlight' the code so make it easier to read/fault find.
Once your IDE (Integrated Development Environment)/Editor is setup - the basic layout of a PHP file is the same as an HTML file:
- All PHP code must be within brackets
- All PHP files must end with extension .php
- Any html code must be within "
hello"; with the semi colon at the end. V important.
- Variables must start with $ sign.
3. Let's test your system with the classic 'hello world' file
- Create yourself a folder on your server for playing around with. I'll call it 'play'
- Enter this into your php ide and save it as a .php file on your computer. Do the same on your computer, create a folder for playing around with so you don't affect your existing (good files).
- Let's call the file 'index.php'
TIP: if you save and upload this file as 'index.php' - the browser will automatically default to it and display it when you refer to the folder name. eg. www.yourdomain.com/play/
<!DOCTYPE html >
<? print "Hello World"; ?>
Now upload the file to your server using ftp
Open up your browser and go to 'www.yourdomain.com/play/
You should get your file showing with hello world up in the top left
Once you've done that, you've proved your environment is working as it should.