Scroll to top

PHP basics

In today’s blog we will be discussing very basic things of PHP i.e. what is PHP and how does a PHP script work!! Also, we will discuss about how to install and setup PHP to run any PHP script.

What is PHP?

PHP is recursive acronym for PreProcessor Hypertext. It is an open source, general purpose, and server side scripting language widely used for web development. PHP is open source means you can download PHP setup and use it for free. PHP is compatible with almost all the servers used today and can run on any OS platform.

PHP files have “.php” extension. PHP files can contain text, HTML, CSS, javascript along with PHP code. PHP files can generate static as well as dynamic webpages.

PHP is scripting language where script is a set of programming instructions given to enhance the performance of an application. A scripting language interprets the script at runtime.

How does PHP script work?

PHP is a server side scripting language means PHP scripts are executed on server and the result is sent to browser in HTML form. When we request for webpage which contains PHP code, the web server will first process the file and output in HTML form is sent back to client’s browser. As PHP statements are processed and only output is sent back, Client never sees the PHP code. With HTML we can design only static pages. PHP is mainly used to develop dynamic pages. Dynamic web pages show different output everytime it is viewed. For example, if we want to display current time of the day on our webpage which will be changing each time the page is viewed, We need to write PHP code that will read the current time and processing this code will display the current time of the day.

Running scripts on server side are much quicker as even though the files are too big, processed output is only downloaded and not the whole file. The processed output in HTML form is usually very much less in size.

How to setup PHP

To write PHP scripts we can use any Text editor software. There are many Text editor softwares available. You can use any, I generally use Notepad++.

If we try to run any .php file by double clicking on it, it will be opened in any text editor software, unlike .htm or .html files, which opens directly in browser. So, to process and run .php files we need to store the .php file into root folder of the web server. If you are using your system as a web server, you must have installed a server in your system. You can check the working of the php webpages on your system without disturbing the working of current upload website.

PHP does not come pre-installed in OS. We need to install PHP manually. To run any PHP file we need to install PHP, Apache server and MySql separately. Instead of installing them separately, we can use XAMPP server, which contains all the three combined and can be installed in a few clicks. There are many other servers also available, for example WAMP server, but it runs only on WINDOWS system. Here, I will be using XAMPP server to demonstrate how to setup PHP and run a PHP file.

How to install XAMPP server and Run PHP file

  • First of all, download the XAMPP from
  • After Extracting the files and you need to double click on the .exe file to install Mysql and Apache server.
  • Once the installation is complete you can use the XAMPP control panel to start or stop the MySql and Apache server.(Before you run any .php file please make sure you have MySql and Apache server Start)
  • Now, all set to run your PHP file. You need to put the .php file into C:/XAMPP/htdocs/ folder. You can then run any .php file, suppose the name of your php file is test.php you need to enter URL http://localhost/test.php into your web browser. The output of the test.php file will be displayed on the browser.

This is how we can setup PHP and run any PHP script. In the next blog we will discuss how to write a PHP script, about PHP variables, comments, etc. using some basic PHP scripts. Thanks!!

Author avatar

Post a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.