PHP Basic concepts

What is PHP?

  1. PHP stands for “PHP: Hypertext Preprocessor”. Initially it was called “personal home page”
  2. PHP is a opensource.PHP costs nothing, it is free to download and use
  3. PHP is a scripting language designed for web.
  4. PHP works with the web server. Ex: Apache, IIS, nginx etc which means that PHP scripts, or programs, usually run on a Web
  5. PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl. So if you have experience with this language, you will be comfortable with php
  6. PHP is a one of the most popular Web programming languages. Using PHP we can build dynamic, interactive Web sites

Syntax

See the below table to get the opening and closing tags of php

Opening Tag Closing Tag
<?php ?>
<? ?> (Short Tag)
<script language=’php’> </script>

Note: To use syntax 2, Short tag must be ‘on’ in php.ini
in php.ini file

short_open_tag=On

PHP File

  1. PHP document with an extension of .php
  2. PHP file contains html, css, javascript, user text and php code
  3. PHP code is parsed on the server. This method of code execution is called “Server Side Code”.
    Note:When code is executed in browser We call that as “Client Side Code”.Ex. Javascript
  4. PHP statement end with semicolon(;)

How PHP Works?

  1. PHP parser finds the requested file and scan it for php code.
  2. When the PHP parser finds PHP code, it executes that code and send back the output to web server
  3. Webserver sends it to web browser and web browser displays the output on screen

Evolution Of PHP

  1. PHP was created by Rasmus Lerdorf way back in 1994. He released PHP to the general public in 1995, and called it PHP version 2
  2. In 1997, two more developers, Zeev Suraski and Andi Gutmans, rewrote most of PHP and, along with Rasmus, released PHP version 3.0 in June 1998.
  3. The new version, PHP 4, was launched in May 2000.
  4. PHP 5, released in July 2004

PHP Advantages

  1. It is easy to learn
  2. It is fast
  3. It is inexpensive. (Free)
  4. It is easy to use
  5. PHP is a cross – platform. It can run on many operating system.
    • Linux
    • Mac
    • Windows
    • Unix
    • Solaris
  6. It is secure
  7. It is designed to support database
    • MS-SQL
    • MYSql
    • Oracle
    • PostgreSQL
    • SQLite
    • IBM DB2
    • and More
  8. It cotains Object-Oriented concept

PHP Comments

Generally Comments in a programming can remind you of what you were thinking when you wrote the code.
A comment in a PHP code is used to understand the program works step by step and then Who created , Who Edited, last modified date etc.
A comment is simply text that is ignored by the PHP engine.

<?php
// This is a single line comment

# This is also a single line comment

/*
This is a multiple lines comment 
This is a multiple lines comment 
*/
?>