Introduction : –
PHP is a language that allows us to develop a website. It is very easy to develop a website in PHP language. It is very easy to create any kind of website in this and PHP is widely used.
What is PHP Language: –
PHP is a scripting language and executed on the server. PHP is open source used for build web applications. PHP is a language in which any type of website can be built. PHP interpreter executes the code on the server. PHP language is free of use. PHP is a widely used language and it is very easy to use and has many frameworks which make web development even easier.
Father Of PHP – “Resmus Lerdorf”
Also Know : –
To do programming in PHP, you need to have knowledge of front end language along with PHP. Before starting with PHP, you must have an understanding of the following languages:-
HTML
CSS
Javascript
History of PHP : –
PHP is a web development programming language created by Rasmus Lerdorf in 1993, and released in 1995. The old name of PHP language was Personal Home Page and now PHP is known by the new name Hypertext Preprocessor. All the features that have been added to PHP since PHP was released till date are mentioned below.
In 1993, Rasmus Lerdorf developed programs in the C programming language, which he used for further improvement of the homepage of his website. These programs were then further developed so that they could be used with forms and databases and Rasmus named it PHP.
On June 8, 1995, Rasmus released version 1.0 under the name PHP Tools.
After this, even more Functionally was added to it and it was made even better and PHP 2 was released in November 1997.
Rasmus said that initially the decision was not to make PHP a programming language as such, but that it was intended to evolve as it progressed. So far many versions have been added to PHP and PHP has become a high level language.
PHP is used for : –
PHP is used for back end development and front end is create with other front end languages. Website user interfaces are built with the front end language and then the back end functionality is built with the PHP language. In the back end the data will be posted and received with the database.
The application programming interface can also be made in PHP. PHP scripting is made according to the Application Programming Interface and is used in app development.
Website Development
Application Programming Interface
Top 10 Advantages Of PHP Language : –
1. Open Source Scripting Language – PHP language is open source script and free of use. It is execute on the server. No license is required to use PHP, anyone can use anywhere and anytime. PHP is a general purpose language.
2. Object Oriented Programming – OOPs is a concept that exists in a large number of languages. Oops concept has many such features due to which many languages use this concept. OOPs is a core concept in PHP. OOPs is a concept of Objects whose full form is Object Oriented Programming. Object means a data which is structured through a class. In object-oriented programming the object is created i.e., the data and code are written and the properties and values in the object are defined in a way. A class can have many objects and all those objects are instances of the class and they have variables, methods, properties and values. oops concept is a concept of many languages.
What is Class ? : Class is a collection of objects. When scripting is start in PHP then a class is created or after that there is a class of functionality in which we define the behavioral data we need.
What is Object ? : Object is a collections of methods, attribute and variables.Each object has attributes and methods according to which the script works and the output is obtained.
3. Database Management System – PHP supports a good database management system. Any kind of hosting can be used in PHP. It is very easy to connect and manage database in PHP.
4. Security – Send request with PHP cross site request forgery token. All URLs are created with https. Regularly updating PHP libraries. PHP Provide session functionality. Object oriented programming is best feature of security in PHP language.
5. Manage Dynamic Content : – PHP controlled all of the dynamic content with using database. PHP send request with any type of data and given usable output to the user.
6. Platform Independent:- PHP can be easily run on any platform. No license is required to run on other platforms. For example Linux, Unix, Mac OS X, Windows. PHP easily installed any platform and using with any editor.
7. Simple And Faster : – PHP language is widely used but still PHP is a very fast running language. PHP is a simple language which is mostly preferred for large scale use.
8. Simple Syntax and Easy To Learn : – PHP is an easily understandable language that can be easily understood or remembered. Syntax of PHP has also been made very simple which is very easy to read and write.
Syntax of PHP –
<?php echo "Hello world"; ?>
9. Case Sensitive – PHP is case sensitive language. Many of PHP statements, method and classes are case sensitive for example : –
Variables
Global Variables
Statements
Loops
10. Interpreted – Interpreter is most important feature and engine of PHP language. Interpreter is convert source code into binary codes. Interpreter is called heart of the PHP Language. Interpreter parse code and given output immediately.
Top Frameworks of PHP –
Laravel FrameWork
CodeIgniter
Symfony
CakePHP
Yii
Disadvantages Of PHP Language : –
Does not support high level websites : – PHP is suitable for ecommerce websites but not high level websites.
Security issues : – Sometimes PHP is not secure because PHP is open source language.
Sometimes other scripting language use : – In PHP, some times other scripting languages have to be used in the web page because the web page does not have to be reloaded, direct action has to be taken.
Slow Performance : – When building high level websites in PHP the performance of the website is very slow and there are some kind of problems.
Lack of debugging : – There is a lack of debugging tool in PHP, due to which there is a problem in error handling.
Lack of built-in functions : – PHP lacks a lot of built-in functions. Most of the functionality in PHP is done by writing a lot of code.
Does not allow application behavior changes : – PHP does not allow online application maintenance or scripting changes.
PHP Installation : –
To develop in PHP language, it is necessary to have PHP and server (hosting) in the system, besides it is necessary to have an editor to write programs in the editor. The server and editor have to be installed correctly according to the steps, otherwise there may be some path or run time errors later.
1. Install Server : – If PHP and Server are not installed in your system, then for that you have to install any server. For example Xampp server. After installing Xampp server, PHP is also installed in it so that you can use PHP extension and write scripts.
Download Xampp server using below link : –
https://www.apachefriends.org/download.html
2. Install Editor :- Development requires an editor, for which you can use any editor. For example Visual Studio Code Editor.
Download Visual Studio Code using below link : –
https://code.visualstudio.com/download
PHP Syntax : –
A syntax is a set of characters and special characters. Syntax is unique to any language, which is written before starting a program in any language.
PHP is written as <?php ?> inside this syntax.
PHP code runs inside the syntax, otherwise an error occurs or it outputs it as a string. It is not that if HTML and PHP code is written then it will not work. PHP is a hypertext preprocessing language which gets preprocessed correctly with html but if we write it with correct syntax. For example see the programme below : –
The following program is written in PHP code embedded in an HTML document:
<!DOCTYPE html> <html> <head> <title>PHP Programme</title> </head> <body> <?php echo '<p>Welcome to PHP language</p>'; ?> </body> </html>
PHP Variable : –
Variables act as containers for storing information in PHP. Variable is declared with $ sign. You can declare the variable with any name like – a, b, x
The following program is How to written variable in PHP:
<?php $a = 5; $a = 6; $sum = $a + $b; echo $sum; ?>
Functions In PHP : –
A function is a set of collections. PHP has many built-in functions and developer can also create custom functions in PHP language.
Syntax of function :
function functionName() { // code here }