What is PHP?
The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web-based software applications. It is created by Rasmus Lerdorf in 1994 who wrote the original Common Gateway Interface (CGI) component, together with Andi Gutmans and Zeev Suraski, who rewrote the parser that formed PHP 3. PHP originally stood for Personal Home Page, but it now stands for the recursive backronym PHP: Hypertext Preprocessor
The best things about using PHP are that it is extremely simple for a newcomer, but offers many advanced features for a professional programmer. Don’t be afraid reading the long list of PHP’s features. You can jump in, in a short time, and start writing simple scripts in a few hours.The latest version of PHP is 7.2.1.
1. It is Friendly with HTML
PHP is very much easy to embed with HTML. PHP can be written in HTML or HTML can also be written inside the PHP.
• PHP inside HTML
<title> PHP in HTML </title>
echo “Hello World”;
• HTML inside PHP
echo “<title>HTML in PHP</title>”;
echo “<h1>Sample 2</h1>”;
echo “Hello World”;
print “<b> More HTML</b>”;
2. Top Class Online Documentation
The documentation of this language is so good that makes learning much easy. Every function and method calls are documented, and most have tons of examples you can study from, along with a great forum that provides a large number of comments from other users.
3. Lots of Resources Available
The resources supporting the PHP are available at tons of places, multiple sites, books, Video Tutorials
4. Cheap AND OPEN SOURCE
The PHP language can be used in free of cost, & some add-ons that are available to enhance the power of PHP are also available at very low cost.
5. Wide Compatibility & Applicability
The PHP is compatible with My-SQL, Oracle, IBM, Postgres, SQLite, Firebase etc. & Used in various major Frameworks like WordPress, CakePHP, CodeIgniter etc.
Where to Start?
Now that you are here, you need not worry about anything. We will guide you step by step about everything. First of all let me make this clear that in order to master any programming skills, you need lots and lots of practice. Even if you are a veteran developer who has worked on 500 live projects, if you stop coding for like 2 months, you will start facing difficulties once you return.
So, no matter what happens you should keep practicing until you get a good hand at this. After this, even if you take a break, you can catch up once you start taking references.
Talking about references, W3Schools is a great place for taking references especially for web development related stuff. I have personally been using W3Schools for quite a while and I am highly impressed by the way they provide the reference for the resources that I am looking out for.What attracts me the most is the fact that they tend to keep their matter updated no matter what. For example, with the released of PHP Version 7, all their matter was updated to take the maximum advantage of what majorly new and better was offered in the newer version. You can switch to this link here for finding more references and new functionalities of PHP.
Pre-requisites for PHP
As the PHP is a web-based language & It is used to establish the client-service relationship that’s why we first require the tools to run PHP.
1. WAMP/XAMPP Server
2. Any Modern Web Browser like Microsoft Edge, Google Chrome or Mozilla Firefox.
3. Any good editor like Visual Studio Code, Notepad++, Sublime Text or the inbuilt Notepad that comes pre-installed with Windows or inbuilt text editor that comes in Linux operating systems too.
The WAMP/XAMPP server is available for free of cost online and Is very easy to install.The download Websites names are mentioned here.
• Download XAMPP for Windows
• Get XAMPP for Linux
• Find XAMPP for MacOS
• Download WAMP for Windows
Installing XAMPP on Windows
Download from above-mentioned websites.
1. Start the Installer
2. Click Next
3. Select All & click on Next
4. Select Directory Where to Install XAMPP
5. Click Next
6. Wait for Setup to install all the files when done click on Finish
Installing XAMPP on Linux (Ubuntu)
Download XAMPP from the links provided above.
1. First move the downloaded file to Home/
2. Now open Terminal and run Command
3. That should start the XAMPP installation setup. Continue with the installation as you usually do.
4. Now Run the Command
sudo /opt/lampp/lampp start
5. Now the htdocs directory is write protected. To remove it rum Command
sudo chmod 777 -R /opt/lampp/htdocs/
How to check If your server is Running
Now its time to check whether the XAMPP is working or not
1. Click on XAMPP icon to start it.
2. Click on Start of both My-SQL & Apache.
3. Now goto Web-Browser.
4. In address run “localhost” If it gets to XAMPP Dashboard then you are on right track.
5. Now, let’s run our first PHP page.
Running the First Program
1. Goto directory C:\xampp\htdocs
2. Create a new file named helloworld.php
3. Paste the following code into the file.
echo “Hello world!”;
4. Save the file & Run this link in Browser.
5. It should give output as
Decrypting the code
Now here, we wrote the <?php tag in order to initiate the PHP script. This tag marks the beginning of writing of the PHP Script.
After this, we write the echo function to write a statement on the webpage. The usage of this function will help in the scenario where the developer wants to print a message again an input from the user. For example, when the user enters a wrong username or a wrong password.
At last, we wrote the ?> tag. This tag is used to close the initiating tag i.e. <?php tag that we used in the beginning of the code.
This was the basics get started and writing your first code lesson for people who are getting new dive in with PHP and we hope you being a beginner will enjoy this journey of getting started with code in PHP. Meet you in the next lesson! 🙂