PHP is a simple yet powerful language designed for creating HTML content. This chapter covers essential background on the PHP language. It describes the nature and history of PHP; which platforms it runs on; and how to download, install, and configure it. This chapter ends by showing you PHP in action, with a quick walkthrough of several PHP programs that illustrate common tasks, such as processing form data, interacting with a database, and creating graphics.
Introduction – PHP
PHP is a server-side scripting language designed primarily for web development but is also used as a general-purpose programming language. Originally created by Rasmus Lerdorf in 1994, the PHP reference implementation is now produced by The PHP Group. PHP originally stood for Personal Home Page, but it now stands for the recursive acronym PHP: Hypertext Preprocessor.
PHP code may be embedded into HTML code, or it can be used in combination with various web template systems, web content management systems and web frameworks. PHP code is usually processed by a PHP interpreter implemented as a module in the web server or as a Common Gateway Interface (CGI) executable. The web server combines the results of the interpreted and executed PHP code, which may be any type of data, including images, with the generated web page. PHP code may also be executed with a command-line interface (CLI) and can be used to implement standalone graphical applications.
The standard PHP interpreter, powered by the Zend Engine, is free software released under the PHP License. PHP has been widely ported and can be deployed on most web servers on almost every operating system and platform, free of charge.
The PHP language evolved without a written formal specification or standard until 2014, leaving the canonical PHP interpreter as a de facto standard. Since 2014 work has gone on to create a formal PHP specification.
Characteristics of PHP
Five important characteristics make PHP’s practical nature possible −
- PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
- PHP supports a wide range of databases
- PHP is compatible with almost all servers used today (Apache, IIS, etc.)
- PHP is free. Download it from the official PHP resource: www.php.net
- PHP is easy to learn and runs efficiently on the server side
What is PHP?
- PHP is an acronym for “PHP: Hypertext Preprocessor”
- PHP scripts are executed on the server
- PHP is a widely-used, open source scripting language
- PHP is free to download and use
- PHP code are executed on the server, and the result is returned to the browser as plain HTML
What is a PHP File?
- PHP files have extension “.php”
What Can PHP Do?
- PHP can generate dynamic page content
- PHP can send and receive cookies
- PHP can create, open, read, write, delete, and close files on the server
- PHP can be used to control user-access
- PHP can collect form data
- PHP can encrypt data
- PHP can add, delete, modify data in your database
You are not limited to output HTML with PHP. You can output PDF files, images, and even Flash . Can also output any text, such as XHTML and XML.
PHP Guide :
What Do I Need?
To start using PHP, When you can:
- Find a web host with PHP and MySQL support
- Install a web server on your own PC, and then install PHP and MySQL
Web Host With PHP Support
If your server has activated support for PHP you do not need to do anything.
Just create some .php files, place them in your web directory, and the server will automatically parse them for you.
You do not need to compile anything or install any extra tools.
Because PHP is free, most web hosts offer PHP support.
Installation PHP On Your Personal Computer
However, if your server does not support PHP, you must:
install a web server
- install PHP
- install a database, such as MySQL
The official PHP.net Has installation Link:
The following “PHP Test Syntax!” program is written in PHP code embedded in an HTML document:
<?php // PHP code type here ?>
Testing For PHP
There is a simple test for both PHP. Open a text editor and type in the following:
<?php phpinfo(); ?>
PHP Programming Examples:
<!DOCTYPE html> <html> <head> <title>PHP Test</title> </head> <body> <?php echo '<p>PHP Test Syntax</p>'; ?> </body> </html>
During the 2010s there have been increased efforts towards standardisation and code sharing in PHP applications by projects such as PHP-FIG in the form of PSR-initiatives as well as Composer dependency manager and the Packagist repository.
PHP Tutorial Part 2 I will introduce PHP Printing Text, Format & Variables.