1// Firstly you must have PHP installed & running a web server
2// This could be Apache, Nginx, etc...
3// Or for quick testing purposes and for the purpose
4// of this example, you could run
5// PHP's own dev server from a shell
6php -S 127.0.0.1:8080 -t your-web-directory-location
7// This will start a web server on localhost port 8080
8// The -t switch sets the document root, this is where your
9// home page, typically index.php will be situated
10
11// very basic index.php example
12<?php
13 echo "Hello, world!";
14?>
15
16// You can now go to a browser and enter 127.0.0.1:8080
17// You will presented with your simple web page
18// Hello, world!
1
2<?php
3echo "Hello world";
4
5// ... more code
6
7echo "Last statement";
8
9// the script ends here with no PHP closing tag
10
11
1<?php
2
3 // This is a comment
4
5 echo 'Hello, World!';
6
7 // And this outputs Hello, World!
8
9?>