PHP is one of the Ps in LAMP (Perl and PHP). Its function is similar to that of HTML::Embperl and HTML::Mason ”it uses executable code embedded in HTML to create dynamic web pages. In the last chapter, we compared Embperl and Mason, and saw that they are similar in purpose. Both can handle most any situation one would come across when developing a web site. Whether one chooses PHP over Embperl or Mason is a matter of personal preference. There are differences, and we try to point them out. The choice is yours. TMTOWTDI (not just with Perl, but with LAMP and Open Source in general). Choice is good! PHP is another of those recursive initialisms beloved of a certain portion of the hacker community [1] ; it's short for PHP: Hypertext Preprocessor. It was developed by Rasmus Lerdorf, Zeev Suraski, Andi Gutmans, and others. The first version was released in 1994; PHP is currently up to version 4.1.1 (as of this writing), while the version released with Red Hat 7 is version 4.0.4.
PHP has many built-in functions that perform important and common requests : It can connect to databases (many types, including MySQL, which we cover here), send e-mail, create PDFs, and more. PHP is widely used, [2] and there are plenty of tutorials, examples, and help available on the Web.
The syntax is similar to Perl, C, and C++, so learning it is not a stretch for the experienced programmer. The ubiquitous flow-control constructs ( if , switch , while , for , and foreach , among others) are available. Grabbing posted data is simple, so form data can be processed easily. The syntax is a bit simpler than Perl. Like Perl, PHP is object oriented, so you can create classes, methods , etc. PHP does have some limitations. For one thing, PHP requires that you learn YAPL. [3] Although PHP has numerous built-in functions to do most things we would need to do, it is not Perl based, as are Embperl and Mason. With Embperl and Mason, you can download and install modules from CPAN and then use them, making Embperl and Mason programs more flexible and extensible. PHP is more self-contained and is slightly more limited than Perl (that's a bit of an understatement ”no reflection on PHP, but Perl is a big language with which one can literally do most anything computer related ).
Hard- core Perl programmers are likely to stay with Embperl or Mason. Others may choose PHP. Try them all and make your own choice. |