PHP scripting - The basic examples
PHP script files consists of plain text, just like a HTML document.
So open your favorite text editor, and type the following:
<?php print "Hello World"; ?>
Save the PHP's files using the extension ".php" – it's mandatory , because it tells the server to how to treat these files, and run the appropriate interpreter to "understand" their contents.
So just go ahead and give it an easy-to-remember name like "helloworld.php". Once the file is saved the Hello World example can be accessed at the http://DOMAIN_NAME.EXTENSION/helloworld.php
Let's say you have the DOMAIN_NAME of test.com the url to the example would be http://test.com/helloworld.php
The server restart is not needed when implementing new scripts, only if the php.ini configuration file is altered.
As above script is pure PHP, the php code could be implemented into a HTML document as well as shown in example below.
<html> <head> <title>PHP Test 2</title> </head> <body> <?php print "<b>Hello Web!</b>"; ?> </body> </html>