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
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.

Categories: PHP. 3 Comments on Creating and running a PHP script
2.8
(8)

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:


Subscribe to our monthly newsletter. Get notified about latest articles, offers and contests.


<?php
	   print "Hello World";
?>

 

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:

 

http://localhost/hello.php

or

http://localhost:80/hello.php

 

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

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Suryateja Pericherla

Suryateja Pericherla, at present is a Research Scholar (full-time Ph.D.) in the Dept. of Computer Science & Systems Engineering at Andhra University, Visakhapatnam. Previously worked as an Associate Professor in the Dept. of CSE at Vishnu Institute of Technology, India.

He has 11+ years of teaching experience and is an individual researcher whose research interests are Cloud Computing, Internet of Things, Computer Security, Network Security and Blockchain.

He is a member of professional societies like IEEE, ACM, CSI and ISCA. He published several research papers which are indexed by SCIE, WoS, Scopus, Springer and others.

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.

3 Comments

You can follow any responses to this entry through the RSS 2.0 feed.

Pretty! This has been an incredibly wonderful article.
Thanks for providing these details.

Spot on with this write-up, I honestly believe this website needs much more
attention. I’ll probably be back again to
see more, thanks for the information!

This info is priceless. When can I find out more?

Leave a Reply

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