Introduction to PHP for the Beginners

PHP is a widely used general-purpose server-side scripting language that is especially used for web development. PHP originally stood for Personal Home Page, but it now stands for Hypertext Preprocessor (recursive acronym).

PHP is available for most of the operating systems and Web servers, and can be integrated with the number of popular databases. It may be run as a separate script or compiled as a module for use with a Web server. The code is executed on the server, generating HTML which is then sent to the client.

The code can be easily embedded within a normal HTML web page or with various templating systems, content management systems (CMS) and web frameworks. The code is executed on the server, and the plain HTML result is sent back to the client (browser).

What Can PHP Do?

There are lot of things it can do. Some of the common things are:

  • It can generate dynamic content in the website.
  • It can perform file operations like create, open, read, write, close on the server.
  • It can send emails.
  • It can collect data.
  • It can handle image upload and manipulation.
  • It can send and receive cookies to track the visitors.
  • It can be used for Authentication and Authorization in website.
  • It can connect to database and perform database operations like adding, deleting, and modifying data in database.

Why PHP?

  • Easy to learn: It is easy to learn and code.
  • Open source: It is an open-source project and it is free.
  • Database Support: It supports a wide range of databases.
  • Portability: It runs on various platforms and is compatible with almost all operating systems and web servers used today.
  • Huge Community: It has a huge worldwide community, it is easier to get help or documentation.

Syntax Overview

The scripts are generally saved with file extension ‘.php‘.

A PHP script is enclosed by opening and closing tags, which are <?php and ?> which tell PHP to start and stop interpreting the code between them. PHP also allows ‘short open tag’ <?…?>.  It is only available by enabling the short_open_tag configuration in php.ini file.

Comments in PHP can be single line (starting with // or #) or multi line (/* … */).

PHP is a case sensitive language but it is insensitive to white space. All keywords, classes, functions, and user defined functions are NOT case sensitive. Variables are case sensitive.

All PHP statements are terminated by semi colon (;). Braces { .. } make blocks.

Leave a Reply