Decisions, decisions, decisions. The glue that holds your web site together, the business rules that control the flow of data, and the navigational structure that guides your visitors from place to place, are all under the control of your web site's logic layer. In programming parlance, this is the "C" (controller) part of the MVC pattern. The logic layer for the server-side back-end is what some consider to the the web "application". But how do you decide which technology is the best fit for this logic?
There are many contenders for supremacy of this layer: Java, Ruby, Active Server Pages, PHP, and a slate of wannabes. And there are a few historical relics still dutifully serving up pages: Perl, CGI using C or C++, and others.
Choosing the right language to implement your business logic is an important consideration. All of them can get the job done. And all of them have strengths that favor certain types of rapid application development. But the real test is whether or not there is a critical mass of software developers using the language. That critical mass is important for maintainability—no matter how beautiful, elegant or efficient your code base is, your web site is doomed without readily available, knowledgeable programmers who can maintain its working operation.
Lately, PHP has become the darling child of this application logic layer, and with that status, it has more readily available programmers than any other server-side language. PHP has become a safe bet for business critical web sites.
PHP is now in it's 5th version. Having learned many important lessons from actual use, the PHP community has continued to strengthen the language in terms of web-safety, object oriented development and namespaces. The language, at this level of maturity now provides everything a programmer needs to get the job done.
As a language that is still evolving, PHP is subject to the normal risks of new technology (old code not working with new versions of the language); but with a large community of talented problem-solving programmers using the language, these risks are minimized.
At some point the evolution of the language will settle down and will seek formal standardization—just as other computer languages have done—with an international body like IETF. In the mean time, the very cutting edge nature of PHP is running in tandem with the cutting edge of the Web.
In its most typical use—as an Apache module—PHP is an interpreted language; that is, there is no compiler and no binary code.
The essence of the language is to inject HTML into a web page at the moment it is needed, allowing you to create pages with custom content that matches your visitor's request.
PHP uses the tagged approach, made popular by ASP, to interrupt normal HTML markup syntax, and to perform some custom action. These tags are sprinkled throughout the HTML page as needed.
<?php= 'Hello world!' ?>
Text injected this way, becomes an integral part of the HTML page.
One of the most useful features of PHP, even for beginners, is its ability to include blocks of text from files. This is the feature that allows standard elements of a web site to be consistent across all pages.
Typically files containing snippets of HTML are built for each of the major page blocks: headers, footers, menus, sidebars, and other decorations. "Including" these files within each page using PHP makes it possible to update every page simultaneously and consistently—simply make any necessary changes once in the appropriate file containing the code snippet.
<?php require_once('/inc/header.php'); ?>
. . .
PHP is a typeless language with automatic declaration of variables at the point of first use. This makes it easy to convert the logic of your pseudo-code into syntactically correct PHP.
Although PHP code is often referred to as a script; the language has all the expressive power and organizational constructs of a full-fledged language: