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:
<?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
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.
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?