PHP Tutorial:As we have already studied in the previous tutorial, What is PHP, PHP is a hugely popular
open-source server-side scripting language. We can create dynamic webpages in it, which enhances the user experience on the website.
A browser doesn't know how to interpret PHP Script, so the server first interprets the PHP Script and then sends the interpreted script to the browser in the form of plain HTML code.
A new catch in using PHP is that because it is a
server-side scripting language so, it needs a server's environment even when you are developing the script in your local machine.
No need to worry about this as there are many software which you can use to create a server environment in the localhost, which is your PC, and then start writing PHP code. But when your website is live, then all the code will be interpreted by the server itself and the client's system need not to have a server installed,
only a browser is enough.
This PHP tutorial will help you to learn PHP in the most simple and easy way with proper examples in each concept. We also have an online PHP editor which you can use to develop PHP applications right from our websites and can also see the output of your code. Stay with us and follow this PHP course to start developing PHP applications and become a PHP developer.
A scripting language is a set of instructions that is interpreted line by line at runtime. Unlike any programming language, scripts are usually embedded within other languages code and enhances their capabilities and features.
The main objective of using a script is to enhance the user experience and application's performance.
Server Side and
Client Side are the two types of scripting languages. Server side are interpreted on the server while the other one is interpreted on the browser installed on client's system.
|Programming language||Scripting language|
|It is used to develop complete applications.||It mostly handles routine tasks.|
|The code is compiled by a compiler.||The code is interpreted by an Interpreter.|
|It in an independent language and not need to be embedded into other languages.||It is embedded with other languages to run.|
|It creates an executable file after compiling.||It does not create a file type.|
|It is used to develop various applications such as desktop, web, mobile etc.||Mostly used for web development.|
Rasmus Lerdorf, the creator of PHP,
"I don't know how to stop it, there was never any intent to write a programming language. I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way."Sounds easy right, well we all know it would have been quite a hectic process. In 1994, Rasmus Lerdorf wrote the very first version of PHP. It was written in
C languageto replace the
PERLcode he has been using on his personal homepage. In 1995, he released the first version of PHP for public use and called it
'Personal Homepage'. After this, the 3rd version was released in 1998 and also got renamed to
PHP was slowly becoming popular day by day and also the newer versions got released frequently which enhanced its features even more. The latest version was released in 2015 which is called
PHP can do many things because of its big library and inbuilt functions and statements. It is the most widely used language for web development globally right now. Some applications of PHP are:
GUI based Applications.
Dynamic web pagesan be created using PHP.
Cookiesefficiently using its pre-built functions.
Data representationis also possible in PHP using tools like Image_Graph.
Oracle, etc. and can manage them accordingly.
file handlingon the server i.e., it can create, open, read, write, delete, and close files on the server.
encryption of datawhich provides safe transmission of the data.
Other than these, PHP can create
flash movies, can do image processing and graphic design also.
It can also create
PDF files by using
We will see many applications of PHP in the tutorial futher.
If you're familiar with other server-side languages like ASP.NET or Java, you might be wondering what makes PHP so special. There are several advantages why one should choose PHP.
free to use, their are no licenses, restrictions, or royalty fees involved which helps in developing a website at minimal cost. As it is open source, developers from all around the world can maintain and develop it further.
PHP is right now unambiguously the most used Scripting language to develop dynamic websites. Some popular websites developed in PHP are:
The first question that arises is that, what would be the extension of a file containing PHP code?
let's see. File extension are very important as it helps the system to identify the type of a
file so that it could run that file in a suitable program. In PHP also if we want the server to identify our PHP
files and scripts, the file should be saved under
The next thing is how to embed PHP code within other languages' code. Well, if we talk about web development, PHP was designed to work with HTML, it can easily be embedded into the HTML code like this:
<HTML> <PHP Code> </HTML>
The PHP code will always be written inside HTML tags
if you want to embed it. A PHP file without HTML tags can also be created, these are called
Pure PHP files because these files only contain PHP's code.
Always remember that whenever you write PHP code it will be written inside
<?php ...... ?> tag.
<script> tags. Even when you embed the PHP code with HTML you have to write it inside the php
tags otherwise the server will not identify the PHP code.
Only the code enclosed within php tags will be interpreted by the server.
Let's see the very first script of PHP, the
'HELLO WORLD' script. The most simple and the first script program any programmer creates on any language. For this, the PHP code has to be embedded with the HTML code.
Look at the example below:
As you can see the php script is written inside the dedicated PHP tags. Now the server will interpret this code and return it in plain HTML format to the browser. Our website is also written in PHP so if you will go through the source code in console you will only find the HTML code because the PHP code is already interpreted by our servers and only the plain HTML code is returned to your browser after the interpretation. Check it out.
There are more than one syntax in which you can write the PHP script but the one we used in the
example is used widely. Let's see other syntax:
From next chapter we will start setting up the server environment in your local machine. Stay with us.