PHP Tutorial – Introduction, Setup Dev Environment, Run PHP Code

Welcome to PHP Tutorial Series and this is the start of this PHP Tutorial Series.

The main topic of This PHP Tutorial Section –

  • PHP Introduction
  • How to set up a PHP Development Environment
  • How to write and run your Frist PHP Code.

PHP Introduction

Introduction of PHP

हिन्दी | PHP Introduction in Hindi

What is PHP?

PHP Stands for PHP Hypertext Preprocessor(PHP). It is a popular open-source server-side scripting language and it was created by Rasmus Lerdorf in 1994.

Main Use of PHP

PHP is basically used to create dynamic websites by interacting with and without the database, and it can be embedded into HTML.

Why Use PHP?

  • Easy to learn
  • Large Community and resources
  • Almost all hosting providers support PHP
  • Most websites on the internet, are created in PHP
  • PHP is compatible with multiple databases including MySQL
  • PHP has lots of frameworks with the large community, such as Laravel, CodeIgniter, etc.

Who use PHP?

Facebook, Wikipedia, Yahoo, Mailchimp, Dailymotion, WordPress etc.

How PHP Code Looks

  echo "Hi, I'm a PHP script!";
Browser Output
Hi, I’m a PHP script!

PHP can be embedded into HTML, but file extension must be .php

<!DOCTYPE html>
        <title>PHP Example</title>
            echo "Hi, I'm a PHP script!";
Browser Output
Hi, I’m a PHP script!

Extension of all PHP files should be .php, like – index.php, home.php, about.php, etc.

Requirements for Learning PHP

  • Basic knowledge of client side and server side scripting
  • You must have knowledge of HTML and CSS.

Setup Dev Environment and Run PHP Code

As we all know that PHP is a server-side scripting language for that we need a server to run PHP.

In the time of learning or development, you do not need to buy any online server. You can run PHP by creating a local or dev server.

How to Create a Local server?

You can create a local server by installing XAMPP software. Or you can use WAMP. But I recommend you use XAMPP.

Why Use XAMPP Software?

First, you need to know if you do not install XAMPP, then you how can set-up your local server?

Without XAMPP you can set-up your PHP Environment by installing Apache Server, MySQL Database OR MariaDB, and PHP.

But, if you will install the XAMPP, then you don’t need to install those applications separately.

XAMPP will install Apache, MariaDB, PHP, and Perl on your Machine.

XAMPP provides you MariaDB, not MySQL DB. Don’t worry, both are almost same.

How to install XAMPP?

How to install Xampp Server in English

How to install the Xampp Server in English

हिन्दी | How to install Xampp Server in Hindi

How to install the Xampp Server in Hindi

First, download the XAMPP from HERE, according to your OS (Mac, Linux, Windows)

XAMPP official website provides very well documentation of XAMPP installation. below, the resources of Xampp installation –

In the installation process, if you face this(see the below image), then ignore the not recommended option and choose another option and then click on Allow access.

XAMPP Firewall

After install the XAMPP, open the htdocs folder. You will find the htdocs folder inside your xampp installation folder.

To open the XAMPP installation folder, Open your XAMPP Control Panel and then click on Explorer. Like the below image –

quick open xampp installation folder
htdocs folder location

Create a shortcut of the htdocs folder on your Desktop, so you can easily access this folder.

Now inside the htdocs folder create a new folder and name it whatever you want, here I named it php_tutorial.

After that go inside the newly created php_tutorial folder and inside this folder create a new file called index.php

To create the index.php you can use Notepad, Notepad ++, Brackets, VS code editor, etc.

How to Write a PHP Code?

Write your first PHP code

हिन्दी | Write your first PHP code in Hindi

PHP code start with <?php and end with ?>

// PHP code goes here

echo is used to show something in output and a PHP statements end with a semicolon;

echo "This is a PHP Statement";
echo "This is another PHP Statement";

How to run PHP Code?


echo "Hi, I'm a PHP script!";

To run index.php open your XAMPP Control panel and start Apache and MySQL. See the below image –

start apache and mysql

After starting the Apache and MySQL, now open your browser and type on URL –

Browser Output
Hi, I’m a PHP script!
  • http://localhost/ – On xampp, localhost targets the htdocs folder by default
  • php_tutorial – php_tutorial is the folder that we created inside the htdocs folder.
  • And index.php is the PHP file that we created inside the php_tutorials folder

Next PHP Tutorial Topic is –

PHP Variables

Leave a Reply

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