Advanced Java and Web Technologies for JNTUK
Blog providing beginner tutorials on different web technologies like HTML, CSS, Javascript, PHP, MYSQL, XML, Java Beans, Servlets, JSP and AJAX

19/02/2014 Categories: PHP. No Comments on Creating and running a PHP script

PHP scripts can be embedded in a (X)HTML document or written separately without any (X)HTML markup. In both cases, the file must be saved with the extension .php.


Creating PHP Script


Any PHP script (code) must be enclosed within the PHP tags which are represented using <?php (opening tag) and ?> (closing tag). Let’s consider a simple PHP script which prints “Hello World” on the web document:



Save the above file as hello.php.


Running PHP Script


To run a PHP script, a web server must be installed and started. Well known web servers are Apache Http Server and Microsoft’s Internet Information Service (IIS).


After a web server is installed, place the PHP file hello.php in the web server’s root directory and start the web server. Now, open a web browser like chrome, firefox or internet explorer and type the following URL in the address bar:






80 is the port at which the web server listens for incoming HTTP requests. The output of the PHP script is:


Hello World


Watch the below video tutorial for creating and running a PHP script


Related Links:

Note: Do you have a question on this article or have a suggestion to make this article better? You can ask or suggest us by filling in the below form. After commenting, your comment will be held for moderation and will be published in 24-48 hrs.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll Up