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<?php
2class BaseClass {
3 public function test() {
4 echo "BaseClass::test() called\n";
5 }
6
7 final public function moreTesting() {
8 echo "BaseClass::moreTesting() called\n";
9 }
10}
11
12class ChildClass extends BaseClass {
13 public function moreTesting() {
14 echo "ChildClass::moreTesting() called\n";
15 }
16}
17// Results in Fatal error: Cannot override final method BaseClass::moreTesting()
18?>
1<!DOCTYPE html>
2
3 <html>
4
5 <body>
6
7
8 <?php
9
10 echo "My first PHP script!";
11
12 ?>
13
14
15
16 </body>
17
18 </html>
19
1<?php $a = “Hello Edureka!”; $b = ‘Hello Edureka!’; echo $a; echo “<br>”; echo $b; ?>
1<?php
2
3 // This is a comment
4
5 echo 'Hello, World!';
6
7 // And this outputs Hello, World!
8
9?>