PHP stands for Hypertext Preprocessor (no, the acronym doesn’t follow the name). It’s an open source, server-side, scripting language used for the development of web applications. By scripting language, we mean a program that is script-based (lines of code) written for the automation of tasks.
What does open source mean? Think of a car manufacturer making the secret to its design models and technology innovations available to anyone interested. These design and technology details can be redistributed, modified, and adopted without the fear of any legal repercussions. The world today might have developed an amazing supercar!
Web pages can be designed using HTML. With HTML, code execution is done on the user’s browser (client-side). On the other hand, with PHP server-side scripting language, it’s executed on the server before it gets to the web browser of the user.
PHP can be embedded in HTML, and it’s well suited for web development and the creation of dynamic web pages for web applications, e-commerce applications, and database applications. It’s considered a friendly language with abilities to easily connect with MySQL, Oracle, and other databases.
PHP scripts can be used on most of the well-known operating systems like Linux, Unix, Solaris, Microsoft Windows, MAC OS and many others. It also supports most web servers including Apache and IIS. Using PHP affords web developers the freedom to choose their operating system and web server.
In PHP, server-side scripting is the main area of operation. Server-side scripting with PHP involves:
- PHP Parser: a program that converts source and human readable code into a format easier for the computer to understand
- Web server: a program that executes files that form web pages from user requests
- Web browser: an application used to display content on the World Wide Web
In this instance, with the use of just a PHP parser, the PHP script can be executed without a server program or browser. This use of the PHP script is normally employed for simple text processing tasks, like task schedulers.
PHP can also be used for creating client-side applications, like desktop applications. Desktop applications are usually characterized by a graphic user interface. With knowledge in using the advanced features of PHP, such as PHP-GTK, these client-side applications can be developed.
The PHP software works with the web server, which is the software that delivers web pages to the world. When you type a URL into your web browser’s address bar, you’re sending a message to the web server at that URL, asking it to send you an HTML file. The web server responds by sending the requested file. Your browser reads the HTML file and displays the web page.
You also request a file from the web server when you click a link in a web page. In addition, the web server processes a file when you click a web page button that submits a form. This process is essentially the same when PHP is installed. You request a file, the web server happens to be running PHP, and it sends HTML back to the browser, thanks to the programming in PHP.
More specifically, when PHP is installed, the web server is configured to expect certain file extensions to contain PHP language statements. Often the extension is .php or .phtml, but any extension can be used. When the web server gets a request for a file with the designated extension, it sends the HTML statements as is, but PHP statements are processed by the PHP software before they’re sent to the requester.
When PHP language statements are processed, only the output, or anything printed to the screen is sent by the web server to the web browser. The PHP language statements, those that don’t produce any output to the screen, aren’t included in the output sent to the browser, so the PHP code is not normally seen by the user.
For instance, in this simple PHP statement, <?php is the PHP opening tag, and ?> is the closing tag.
<?php echo "<p>Hello World</p>"; ?>
Here, echo is a PHP instruction that tells PHP to output the upcoming text. The PHP software processes the PHP statement and outputs the following:
That regular HTML statement is delivered to the user’s browser. The browser interprets the statement as HTML code and displays a web page with one paragraph — Hello World. The PHP statement isn’t delivered to the browser, so the user never sees any PHP statements. PHP and the web server must work closely together.
PHP isn’t integrated with all web servers but does work with many of the popular web servers. PHP works well with the Apache web server. PHP also works with Microsoft Internet Information Services (IIS) and others.