•  What is PHP?
    • PHP is a scripting language that is used to create web application
    • PHP is an acronym for "Hypertext Preprocessor".
    • PHP is widely used because it is Open Source scripting language (free to download and use)
    • Rasmus Lerdorf is the Father of PHP.
  • Why PHP?
    • PHP can be installed on any OS(Windows, Linux, Unix, Mac OS X, etc.)
    • PHP supports a wide range of Database(MySQL, Oracle, Sybase, Generic ODBC, etc.)
    • PHP is free, it can be downloaded from the official PHP website(www.php.net)
    • PHP is an easy to Learn and Run efficiently on the Server-side.
  • What can PHP do?
    • PHP can generate dynamic page content
    • PHP can perform file handling operations likes(create, open, read, write, delete and close).
    • PHP can send and receive cookie values.
    • PHP can perform Database handling operations likes(add, delete, modify data in your database).
    • PHP can be used to control user-access.
    • PHP can encrypt data.
  • Where we use PHP?
    • For Server-side Scripting
      • Dynamic web pages
    • For Building Client-side GUI Application
      • Desktop Application
    • For Command Line Scripting
      • Task Scheduling on windows
      • Text processing tasks, etc
    • E-commerce sites(flipkart, amazon, ebay, etc.)
    • Project Management Tools.
    • Social Application like Facebook.
    • to create Graph and Chart.
    • to create CMS (Content Management System).
  • Advantages of PHP
    • Open Source: PHP is readily available and free to use.
    • Community: PHP has a large base of users and developers. So lots of information and support is readily available. High availability of libraries and APIs.
    • Simple and easy to learn.
    • Cross-Platform: PHP runs on any platform and support wide range of web servers(Apache, IIS, etc.)
  • Dis-Advantages of PHP
    • Building complex project is difficult: Required lot of support from experienced PHP programmers.
    • Open Source Code: Lack of debugging tools.
    • Versions are constantly changing.
    • Inconsistency: Because we have random functions, random parameters, random return values, etc.
  • How PHP works?
    • Here we show PHP file interprets and interact with server or database.
How PHP Works Diagram?



    1. user's web browser sends a request to the web server where the site is hosted.
    2. If the requested webpage has PHP extension, then web server forward it to the PHP interpreter that is installed on the web server.
    3. PHP interpreter executes the PHP code. If PHP script written for Database then it sends or receive information from database. after that it generates output as HTML code and sends it to web server.
    4. And finally, the web server sends the HTML output to the requested user browser.
Note: PHP interpreter handles data before it becomes HTML, therefore, it is called PHP: Hypertext Preprocessor. 
  • Required Component for PHP Environment Setup
    1. Webserver-Apache
    2. Database Server-MySQL
    3. Web Programming Language-PHP.
    4. Database Management Tool-phpMyAdmin.
  • There are two ways to installation:
    1. To install all the components separately.
      1. APACHE:        https://httpd.apache.org/download.cgi
      2. MYSQL:          https://www.mysql.com/downloads/
      3. PHP:                 https://www.php.net/downloads.php
      4. phpMyAdmin: https://www.phpmyadmin.net/
    2. to install from all in one package:
      1. LAMP:     Linux, Apache, MySQL and PHP.
      2. WAMP:    Windows, Apache, MySQL and PHP. 
      3. MAMP:    Mac, Apache, MySQL and PHP.
      4. XAMMP: X-OS (any Operating System), Apache, MySQL and PHP and Perl.
  • General Troubleshooting Tips:
    • Error:-If Apache server does not start then there can be a PORT conflict in apache server.
      • Solution: open Xampp/Apache/conf/httpd.conf file and change listen 80 to (90,8888, any other than 80 but don't use reserve PORT).
    • If MySQL PORT conflict occurs then we can change port as.
      • Solution: open Xampp/MySQL/bin/my.ini file and change PORT 3306 to 3307.