Originally Published: Sunday, 23 January 2000 Author: Jeff Alami
Published to: featured_articles/Featured Articles Page: 1/1 - [Printable]

PHP Questions

A great deal of Linux users have heard about PHP, the Hypertext Preprocessor. PHP is the engine behind many dynamic Web sites, including this one, Linux.com. Recently, a friend of mine asked a few general questions about PHP. I thought that it would be worthwhile to share my responses with our readers....

   Page 1 of 1  

A great deal of Linux users have heard about PHP, the Hypertext Preprocessor. PHP is the engine behind many dynamic Web sites, including this one, Linux.com. Recently, a friend of mine asked a few general questions about PHP. I thought that it would be worthwhile to share my responses with our readers.

What is PHP?

PHP is a scripting language, much like Perl or Python, which is embedded in HTML to create dynamic Web sites. PHP's syntax is drawn mostly from C and Perl. According to Netcraft, PHP is being used by over a million domains on the Internet.

Is PHP a safer alternative to CGI?

You can run into security problems with some CGI implementations. If you develop a CGI script in C, for example, you could run into buffer overflows which lead to root exploits. Similarly, you can run into security problems if malicious users cause Perl scripts to invoke processes on the server system.

PHP takes care of many common security issues for you. PHP isn't completely risk-free in terms of security, however. If you have a badly written script and don't check for invalid data, you could still run into problems. Of course, you will want to keep an eye out for security notices in Apache and the mod_php3 module.

Is PHP a convenient way to retrieve data from a database?

PHP was designed from the ground up to deal with databases. Many PHP implementations use the (very fast and stable) MySQL server, and many other database servers are supported, including Oracle, Sybase, Informix, and PostgreSQL. You can also access large text databases, due to PHP's good text handling capabilities.

Are there known drawbacks to PHP?

The primary drawback of PHP3 is the lack of decent object-oriented features. PHP4 will solve several of PHP3's shortcomings by having OOP, script compilation, speed increases, added functionality, session handling, and more.

Is it easy to configure Apache to handle PHP?

Yes, it is easy to configure. In the Red Hat and Debian distributions, for example, all you need to do is install the Apache and mod_php3 packages, and you're practically set. You'll simply need to take a look at Apache's httpd.conf configuration file to make sure PHP is enabled.

Otherwise, if you want Apache and PHP compiled exactly the way you want it, check out the Web Database Step-by-Step Guide. The guide is a bit out of date when it comes to version numbers. But if you follow the steps using the newest versions of Apache and PHP, you can get your server set up with the guide's instructions.

Should you install it and get working with it?

The answer is a resounding yes. At home, I have a server running Apache, PHP, and MySQL, and it's a great deal of fun to work with. Within hours, you'll be making dynamic Web sites with ease. To find out more about PHP, check out the PHP Web site and PHPBuilder.com.

For the production environment, it's a case of selecting the right tool for the job. PHP happens to suit Linux.com quite nicely. Other sites may want to use mod_perl, or CGI, or a custom module, or a custom Web server, or something entirely different, depending on what their needs are.

Have fun with PHP!

Jeff Alami (jeff@linux.com) admits it: he has no real life. When he's not working as the Editor-in-Chief of Linux.com, he's either sleeping or eating. Come to think of it, he doesn't spend much time sleeping or eating anyway.





   Page 1 of 1