As shown in the diagram above, the PHP interpreter processes the page, communicating with file systems, databases, and email servers as necessary, and then delivers a web page to the web server to return to the browser.
PHP scripting
PHP is now officially known as "PHP: HyperText Preprocessor". It is a server-side scripting language usually written in an HTML context. Unlike an ordinary HTML page, a PHP script is not sent directly to a client by the server; instead, it is parsed by the PHP binary or module, which is server-side installed. HTML elements in the script are left alone, but PHP code is interpreted and executed. PHP code in a script can query databases, create images, read and write files, talk to remote servers – the possibilities are endless. The output from PHP code is combined with the HTML in the script and the result sent to the users web-browser, therefore it can never tell the user whether the web-server uses PHP or not, because all the browser sees is HTML.
PHP goes right into your Web pages, so there's no need for a special development environment or IDE. You start a block of PHP code with . (You can also configure PHP to use ASP-style tags or even .) The PHP engine processes everything between those tags.
PHP's language syntax is similar to C's and Perl's. You don't have to declare variables before you use them, and it's easy to create arrays and hashes (associative arrays). PHP even has some rudimentary object-oriented features, providing a helpful way to organize and encapsulate your code.
Although PHP runs fastest embedded in Apache, there are instructions on the PHP Web site for seamless setup with Microsoft IIS and Netscape Enterprise Server. If you don't already have a copy of PHP, you can download it at the official Web site. You'll also find a manual that documents all of PHP's functions and features.
That does not mean that PHP cannot work in other environments or with other tools. In fact, PHP supports an extensive list of databases and web-servers. The rise in popularity of PHP has coincided with a change of approach in web-publishing. While in the mid-1990s it was ok to build sites, even relatively large sites, with hundreds of individual hard-coded HTML pages, today’s webmasters are making the most of the power of databases to manage their content more effectively and to personalize their sites according to individual user preferences.
The endless possibilities of the PHP scripting language and a great community of users has made it one of the most popular open-source languages. For all you people living outside the UNIX world, Open Source means it doesn't cost anything. You can use it as much as you want and where you want, and nobody will ever charge you thousands of dollars for licenses and support. Even though it was originally conceived as a set of macros to help coders maintain personal home pages, its name grew a lot more from its purpose. Since then, PHP's capabilities have been extended, taking it beyond a set of utilities to a full-featured programming language, capable of managing huge database-driven online environments.
PHP's support for Apache and MySQL further increases its popularity. Apache is now the most-used web-server in the world, and PHP can be compiled as an Apache module. MySQL is a powerful free SQL database, and PHP provides a comprehensive set of functions for working with it. The combination of Apache, MySQL and PHP is all but unbeatable.
Reasons for using PHP
There are some indisputable great reasons to work with PHP. As an open source product, PHP is well supported by a talented production team and a committed user community. Furthermore, PHP can be run on all the major operating systems with most servers.
The speed of development is also important. Because PHP allows you to separate HTML code from scripted elements, you will notice a significant decrease in development time on many projects. In many instances, you will be able to separate the coding stage of a project from the design and build stages. Not only can this make life easier for you as a programmer, but it also can remove obstacles that stand in the way of effective and flexible design.
Well-maintained open source projects offer users additional benefits. You benefit from an accessible and committed community who offer a wealth of experience in the subject, as fast and as cheap as possible. Chances are that any problem you encounter in your coding can be answered swiftly and easily with a little research. If that fails, a question sent to a mailing list or forum can have an intelligent, authoritative response. You also can be sure that bugs will be addressed as they are found, and that new features will be made available as the need is defined. You will not have to wait for the next commercial release before taking advantage of improvements, and there is no hidden interest in a particular server product or operating system. You are free to make choices that suit your needs or those of your clients and incorporate whatever components you want.
|
PHP can collect user information - By this, you can let your user directly interact with the script. This can be something really |
|
simple, like collecting the temperature from the user that they want to convert from degrees to another format, or it can be |
|
more extensive information, like adding their information to an address book, or letting them post on a forum. |
|
|
|
PHP can interact with MySQL databases - And in doing this, the possibilities are endless. You can write users information to the |
|
database and you can retrieve information from the database. This allows you to create pages on the fly using the contents of |
|
the database. Youcan even do more complex things like setting up a login system, creating a website search feature, |
|
or keep your store's product catalogue and inventory online. |
|
|
|
You can use PHP to write practically any type of Web application or script. Common PHP applications include: |
|
Blogging software such as WordPress |
|
E-commerce systems like Magento |
|
Content management systems including Drupal and Joomla!, and |
|
Forum software such as phpBB |
|
|
|
In addition, many popular websites, including Yahoo!, Wikipedia, Facebook, and Digg, use PHP code extensively. |
|
|
PHP - What's it do? |
|
It is also helpful to think of PHP in terms of what it can do for you. PHP will allow you to: |
|
Reduce the time to create large websites. |
|
Create a customized user experience for visitors based on information that you have gathered from them. |
|
Open up thousands of possibilities for online tools. Check out PHP - HotScripts for examples of the great things that are possible with PHP. |
|
Allow creation of shopping carts for e-commerce websites. |
PHP and GD Library can create graphics - You can use PHP to create simple graphics on the fly. You can also use it to edit existing graphics. You might want to do this to resize images, rotate them, or grey scale them. Some practical applications for this are allowing users to edit their avatars or creating CAPTCHA verifications. You can also create dynamic graphics that are always changing, my favorite example being dynamic twitter signatures. |