11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 11 • PEARwww.it-ebooks.infodate on the web site must appear in this format. Take a moment to think about this requirement becausefulfilling it isn’t as easy as it may sound. Of course, you could look up a conversion table online andhard-code the values, but how would you ensure that the site copyright year in the page footer is alwaysup to date? You’re just about to settle in for a long evening of coding when you pause for a moment toconsider whether somebody else has encountered a similar problem. “No way,” you mutter, but taking aquick moment to search PEAR certainly would be worth the trouble. You navigate over and, sureenough, encounter Numbers_Roman.For the purpose of this exercise, assume that the Numbers_Roman package has been installed on theserver. (You’ll learn how to install packages in the next section.) How would you go about making surethe current year is displayed in the footer? You could use the following script:// Output the copyright statementecho "Copyright &copy; $romanyear";For the year 2010, this script would produce the following:Copyright © MMXThe moral of this story? Even if you think that a particular problem is obscure, other programmerslikely have faced a similar problem. If you’re fortunate enough, a solution is readily available and yoursfor the taking.Installing and Updating PEARPEAR has become such an important aspect of efficient <strong>PHP</strong> programming that it has been includedwith the distribution since version 4.3.0. Therefore, if you’re running this version or later, feel free tojump ahead and review the section “Updating Pear.” If you’re running <strong>PHP</strong> version 4.2.X or earlier, thissection will show you how to install the PEAR Package Manager on both the Linux and Windowsplatforms. Because many readers run Web sites on a shared hosting provider, this section also explainshow to take advantage of PEAR without running the Package Manager.Installing PEARInstalling PEAR on both Linux and Windows is a trivial matter, accomplished with a few simplecommands. Instructions for both operating systems are provided in the following two subsections. I’ll258

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!