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

Suryateja Pericherla

Suryateja Pericherla

Hello, I am Suryateja Pericherla working as an Asst. Professor in CSE department at Vishnu Institute of Technology. I write articles to share my knowledge and make people knowledgeable regarding certain topics.
Suryateja Pericherla

Latest posts by Suryateja Pericherla (see all)

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

Scroll Up
Thank you for visiting! If you like this website do share with your friends by clicking on the social icons available on the left hand side.

As the domain name is quite large to remember, use this short domain to visit this site. Short domain: