Introduction to PHP
In this tutorial we go over PHP as a programming language, what it's used for and why you should learn this powerful programming language to develop your dynamic website.
We also cover the learning level of difficulty and any prerequisites needed.
Here's a table of contents of what you'll learn in this lesson:
(click on a link to skip to its section)
Let's jump right in.
What is PHP?
PHP is a scripting language used to develop static and dynamic web pages and web applications. PHP stands for Hypertext Pre-Processor.
PHP was created in 1994 by Rasmus Lerdorf. The first incarnation of PHP was a set of CGI (Common Gateway Interface) binaries written in the C language.
What is PHP used for?
PHP dominates the web space in terms of a server-side application language. PHP can be found in most of the web.
Content Management Systems:
PHP is widely used in web development. About 78% of developers on the web use PHP as their server-side language of choice.
- PHP is cross platform.
- PHP can easily interface with Apache, MySQL, Java and various other technologies.
- PHP allows easy database connection through built-in modules and significantly reduces time needed in developing data-driven web applications.
- PHP is interpreted, there is no need for a compiler.
- PHP is Open Source. It's readily available and entirely free.
- PHP is easy to use. It has a well-organized syntax which is simple, fluent, clean and logical.
- PHP is widely used and as such, have a well established internet community that can answer almost any question.
- PHP is faster than other scripting languages like ASP and JSP.
- Create Facebook applications, and easily integrate Facebook plugins in your website with Facebook's PHP SDK.
- PHP has poor error handling. PHP lacks the debugging tools available in other languages which are often needed to search for errors and warnings.
However, as mentioned above, one of its advantages is that the PHP community is so big that help can easily be found on the internet. If a problem exists, it has probably already been asked and answered somewhere.
Is PHP hard to learn?
Even though PHP has become more complex in recent versions, it remains one of the easiest languages to learn. It doesn’t require intensive studying and is easily understood, which makes it perfect for beginners.
Before we proceed, please note that we make the following assumptions:
- You know how to install software on whichever operating system you use.
- You can create and navigate directories and files on your computer.
It is beneficial to know other web technologies such as HTML and CSS but not strictly necessary as we will cover some small amounts of it, when needed, in this tutorial series.
While this tutorial series is for beginners with no knowledge of PHP or programming in general, programmers coming from other languages that want to learn PHP will also find it very helpful.
This tutorial series covers many topics of programming in PHP, ranging from beginner concepts to advanced.
PHP Development Environment Setup
A development environment is all the tools and procedures that is necessary to develop, test and debug an application.
In the following tutorials we will learn how to set up a PHP environment with a free IDE, PHP Parser, server, database, control panel, and more.
What is needed to develop in PHP
To develop a PHP application we require the following:
- PHP Parser. The parser will process all PHP scripts and generate the HTML output.
- Web Server. A web server is that serves files to users in the form of web pages. PHP can be installed on virtually any web server such as Apache or Nginx.
- Database (optional). A database is used for long term storage on a server. PHP can be used with many database systems such as Oracle, MySQL, MariaDB, or PostgreSQL.
- Text editor or IDE. We need, at least, a simple text editor application to type out our PHP scripts. Most commonly, an IDE (integrated development environment) is used which provides us with more ease-of-use functionality than a simple text editor can.
In this PHP tutorial series we will use the following:
- Atom free IDE
- XAMPP free PHP development environment. Includes the Apache web server, PHP parser and MariaDB database, among others.
List of Tutorials
Development Environment Setup Your first PHP application Variables Keywords & Identifiers Comments Constants Data Types Operators Arrays
Conditional Control: if, else, switch, ternary Iteration Control: do, while, foreach, for loops Control statements: break and continue
Multi-dimensional arrays Functions Include & Require
Basic Form Handling Basic Form Validation
Sessions & Cookies
Basic File Handling
OOP: Classes & Objects OOP: $this calling object OOP: Constructors & Destructors OOP: Inheritance OOP: Polymorphism OOP: Composition OOP: Encapsulation - Access Modifiers Interfaces
Error & Exception Handling
MySQL/MariaDB Connect & Disconnect Create a database Create a database table Insert data Select data Update data Delete data