loading...
Cover image for Intro to PHP for Beginners (Module 1)

Intro to PHP for Beginners (Module 1)

kh4l33l profile image Ibrahim Nasir ・4 min read

1. Introduction to PHP

PHP is an intuitive, server side scripting language, it is a recursive acronym for “PHP: Hypertext Preprocessor” -- It is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
This programming language is very easy to learn. Being an open source any individual can easily develop a web application. It has become a very vast platform now for all kind free sourcing development.
This backend workspace plays a very vital role in the development of a web technology and Content Management Systems (eg. WordPress, Joomla and Magento).

Web Architecture

An Architecture Diagram is a logical diagram that shows how each of the components in a system is connected with each other and how are the data flowing between. If we draw architecture diagram for a typical PHP based web application it will be like the below diagram.

The numbers I used below beside the Label names following 1 for Request flow and 2 for response flow.

  • A1: First user accessed the website through browser. That means user types the URL of the website in browser and hit go.
  • B1: The page request on browser will reach to the Web Server (Apache).
  • C: Web server will collect that requested page (HTML or PHP or Image file etc) from its document root. (In our example it will be www folder in WAMP. You will see it in next one)
  • B2: Now if it is a static element like HTML, CSS , image file or Java Script file then Apache will send it directly to browser.
  • A2: And Browser will render it to user on screen
  • D1: If it is a PHP file then Apache sends the content of the file to PHP Interpreter. PHP interpreter interprets the PHP code and executes it. if DB operation is required it performs the same (E)
  • D2: PHP Interpreter generates output (if the PHP code is to generate any output) and sends to Apache
  • B2: Apache sends that content to browser
  • A2: Browser renders it to users' screen All static components like HTML, CSS files, Image Files, Java Scripts etc doesn't need interpreter. Our web browsers are built to render them and display on screen properly. That is why if user requests for these kind of components Apache collects them from Document root and sends back to Browser directly.

Overview of PHP Platform

PHP is an intuitive, server side scripting language. Like any other scripting language it allows developers to build logic into the creation of web page content and handle data returned from a web browser. PHP also contains a number of extensions that make it easy to interact with databases, extracting data to be displayed on a web page and storing information entered by a web site visitor back into the database.
PHP consists of a scripting language and an interpreter. Like other scripting languages, PHP enables web developers to define the behavior and logic they need in a web page. These scripts are embedded into the HTML documents that are served by the web server. The interpreter takes the form of a module that integrates into the web server, converting the scripts into commands the computer then executes to achieve the results defined in the script by the web developer.

Origins of PHP in the open source community

The first version of what came to be known as PHP was created in 1995 by a man named Rasmus Lerdof. Rasmus, now an engineer at Yahoo!, needed something to make it easier to create content on his web site, something that would work well with HTML, yet give him power and flexibility beyond what HTML could offer him. Essentially, what he needed was an easy way to write scripts that would run on his web server both to create content, and handle data being passed back to the server from the web browser. Using the Perl language, he created some technology that gave him what he needed and decided to call this technology "Personal Home Page/Forms Interpreter". The technology provided a convenient way to process web forms and create content.
The name "Personal Home Page/Forms Interpreter" was later shortened to PHP/FI and eventually renamed to represent "PHP: Hypertext Preprocessor". The name is said to be recursive because the full name also includes the acronym "PHP" - an odd geeky joke that is common in technology circles when people have trouble naming things. GNU is another recursive name that represents "GNU's Not Unix".
PHP/FI version 1.0 was never really used outside of Rasmus' own web site. With the introduction of PHP/FI 2.0 this began to change. When PHP 3 was released in 1997, adoption of PHP exploded beyond all belief.

Why we use PHP?

o PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
o PHP is compatible with almost all servers used today (Apache, IIS, etc.)
o PHP supports a wide range of databases
o PHP is free. Download it from the official PHP resource: www.php.net
o PHP is easy to learn and runs efficiently on the server side

Some of PHP's strengths:

o PHP can generate dynamic page content
o PHP can create, open, read, write, delete, and close files on the server
o PHP can collect form data
o PHP can send and receive cookies
o PHP can add, delete, modify data in your database
o PHP can be used to control user-access
o PHP can encrypt data

Some of PHP's main competitors are PERL, Microsoft ASP.NET, Java Server Page

Though PHP competes against these other solutions, none of these languages are as easy to learn as PHP.

Availability across multiple platforms

A user can use PHP with Windows, Linux, or Macs.

Installing as a module for Apache Web Server

There are some excellent all-in-one Windows distributions that contain Apache, PHP, MySQL and other applications in a single installation file, e.g. XAMPP (including a Mac version) and WAMP Server but manually installing Apache and PHP helps to learn more about the system and its configuration options.

Posted on by:

Discussion

pic
Editor guide
 

Precise article Ibrahim!
Awesome introduction.

 

Thank you Boss!