Getting Started with PHP
PHP is a popular open-source general-purpose HTML-embedded server-side scripting language, which enables web developers to create dynamically generated web pages quickly. PHP was originally created by Rasmus Lerdorf in 1995, who added web forms that communicate with database (based on CGI/Perl) and called it “Personal Home Page/Forms Interpreter” or PHP/FI. PHP is now said to stand for “PHP: Hypertext Preprocessor” (a recursive acronym similar to GNU – GNU is Not Unix). PHP is now maintained by “The PHP Group” (@ http://www.php.net).
PHP is great for a one-man-operated (or two-man-operated) project, where a technically proficient geek can quickly produce a working prototype for a webapp. However, it is hard to use PHP to write good MVC (Model-View-Control) webapp, where the data (model), presentation (view) and logic (control) are well separated to facilitate team collaboration and maintenance. There are many PHP MVC frameworks (or libraries that run on top of PHP), such as Zend, CakePHP, Yii, Symfony and CodeIgniter. However, the learning curve of using these frameworks could be steep.
Other HTML-embedded server-side scripting languages are: Microsoft’s ASP (Active Server Pages), Java’s JSP (Java Server Pages), CGI/Perl and etc.
Modes of Operation
PHP operates in two modes:
- Standalone Command-line Interface (CLI): You can run a CLI PHP script by itself, just like any program written in Perl/Python or C/C++/Java.
- HTML-embedded Server-side Script: The server-side script must be run under a PHP-capable Web Server (such as Apache HTTP Server).
We shall focus on PHP Server-side script, as it is what PHP is most often used.
This article is NOT for the dummies. The pre-requisites are:
- For OOP: basic knowledge of OOP.