Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
PHP Books Media Programming Book Reviews

Programming PHP 228

dooling writes "Continuing the tradition of well written O'Reilly 'Programming' books by those who know the language best, Programming PHP, co-written by the creator of PHP, Rasmus Lerdorf, provides a detailed overview of the popular PHP web-page scripting language. This book provides good programmers who have never used PHP enough information to do serious web development using PHP and serves as an excellent reference for web-page designers who dabble in PHP." Read on for the rest of his review.
Programming PHP
author Rasmus Lerdorf & Kevin Tatroe
pages 507
publisher O'Reilly and Associates
rating 7
reviewer dooling
ISBN 1565926102
summary great PHP book for serious programmers, good reference
While not as entertaining as Programming Perl, it isn't nearly as long either (and doesn't have to be). The book is written in a straightforward style and is very well organized. Appendices provide quick reference to all the PHP built-in functions and many PHP extensions. The most popular extensions, e.g., PEAR DB (database connectivity) and XML, have entire chapters devoted to them. Can't find a PHP extension for your favorite library? There's a chapter about writing your own PHP extensions, including writing C library wrappers.

This book begins as most O'Reilly "Programming" books do: with a brief introductory chapter. In Programming PHP, this chapter is very short, so don't look to this book for a gentle introduction. On the other hand, this is the perfect book for you if you are just looking to learn a new scripting language. The following chapters go over syntax, data types, built-in functions, etc. These chapters are a little dry, but move quickly and effectively demonstrate the unique features of PHP (as compared to other scripting languages).

Of particular interest to programmers who are interested in expanding their horizons to developing dynamic web pages are the chapters on PHP web techniques, security, and application techniques. The web techniques chapter gives a quick overview of HTML and the GET and POST methods (and why you would want to use one or the other). It then covers a lot of useful tips and tricks that may be foreign to someone who has done little or no web development. Topics such as getting server information, form processing, sticky forms, file uploads, document expiration, and authentication are covered. It ends with an excellent discussion of maintaining state from page to page and visit to visit, covering cookies and PHP's (very cool) session support.

The security chapter covers standard things you want to keep in mind when creating dynamic HTML. No surprises here, but it is always good to be reminded. The application techniques chapter starts with a collection of best-practices, tips, and tricks to make your development process easier and better. It concludes with sections about error handling and performance tuning. As with the security chapter, there is nothing here a good programmer doesn't already know, but you can never hear it too many times.

I think this is a great book for programmers who want to start developing dynamic web sites with PHP. It gives a detailed overview of PHP, lots of valuable tips, and a good sense of PHP's strengths.

As someone who has written a lot of code, but only a little CGI, I really liked the chapters that discussed application development techniques specific to the web. Along those lines, not much time is spent on standard coding techniques, so if you want to use PHP but have never written any serious code, you may want to look elsewhere for an introduction. For the rest of you, just think, you may never have to use CGI.pm again.

The index seems adequate, although I must admit I did not use it much on the first read-through. The book is so well organized that, when reading it, you do not have to flip around much. Perhaps someone who has used this book as a reference can comment further on the quality of the index.

Contents are available on O'Reilly's page Links

See Rasmus's page for links to where you can buy the book (maybe he gets a kickback for the link). Of course, you could always go to a local bookstore and purchase it.


You can purchase Programming PHP from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

This discussion has been archived. No new comments can be posted.

Programming PHP

Comments Filter:
  • PHP Security Papers (Score:1, Interesting)

    by Anonymous Coward
    www.cgisecurity.com/lib [cgisecurity.com]
  • Isn't this a contradiction:

    This book provides good programmers who have never used PHP enough information to do serious web development using PHP

    and

    so if you want to use PHP but have never written any serious code, you may want to look elsewhere for an introduction

    So is it good for newbies or not?
    • by alnapp ( 321260 ) on Thursday September 12, 2002 @10:09AM (#4244763) Homepage
      No contradiction:

      You're an accomplished programmer but a PHP newbie then buy it.
      Your a newbie to programming then there's prolly a "for dummies" out there.

      Or, HIBT HIL and I'm having a nice day thank-you
    • This book provides good programmers who have never used PHP enough information to do serious web development using PHP

      Those who are experienced with another language will find this book useful for picking up PHP.

      so if you want to use PHP but have never written any serious code, you may want to look elsewhere for an introduction

      ..if, however, you don't have experience in any programming language, you'd be best to find a book that spends more time covering coding basics.

    • Good for newbies to PHP, not newbies to programming.
    • It's not a contradiction. It basically says that if you've ever written (good?) code, not necessarily in PHP, this is a good reference to get you introduced to the nuances of the language. However, if you're a total neophyte, and have never written code in any language, then this would not be the way to go.
  • It redefines the paradigm of online programming. Programming PHP, like PHP itself, marks a watershed in programming history. Generations from now technology historians will divide the time line into two periods: PPHP (Pre-PHP) and PPHP (Post-PHP). The PHP language, just like the book describing it, is beyond compare. Coupled together they have created a force for Good that rivals Superman, God and Scooby Doo all rolled into one. My next child is going to be named "PHP Programming Lastname".
  • by $rtbl_this ( 584653 ) on Thursday September 12, 2002 @10:14AM (#4244806)

    As a semi-competent Perl hacker I found PHP very easy to pick up, and I imagine the same would be true for anyone with some degree of coding experience. The only reference I find myself using regularly is the excellent PHP website [php.net] which provides a pretty decent tutorial and a thorough and searchable command reference. Combine that with the fact that the manual is annotated by PHP users and the only reason for having a dead tree reference is to have something to read in the bath.

    Still, buying it does at least give Rasmus some money...

    • I agree completely with you. And to append on to what you said. Most books that come out on PHP are already out of date as far as the all the new functions that PHP has. This isn't a rib on the writers of the PHP books, it's just because of the time it takes to write the book, go through the publishing process and get the book shipped.

      By then new functions have come out and the book that was supposed to cover PHP is now obsolete.

      And again as much as I respect the writers and publishers of the PHP books, I find my times the comments below the functions on php's website to be more helpful than any book.
    • I used to read documentation with my laptop while in my bath. Way cheaper than buying those dead tree books.

      I thought it was a good idea until I had to call tech support and they told me that it was not considered 'normal use' for the warranty. It only takes tech support people to say that taking a bath/shower is not normal I guess.
    • If only all documentation was as good as the php website. Seriously it's fantastic, other languages should follow in it's example. I think it's a big factor of php's success myself. Recently I had some questions about apache 2 and php, I asked them on opn in #php and who answers me but rasmus himself. How cool is that? (Ok it's irc.. it can't be that cool but you know what I mean)
      • Yeah, but how hard is answering a question on PHP and apache 2? The only 2 possible answers are "It might work" and "It doesn't work".

        :-)
      • The two best documentation sites I've seen are PHP and Qt's. I wish there was a good html reference site - w3c's and Netscapes don't document IE's irregularities. Nor does MSDN's (which is my favorite), although it at least documents Netscape's quirks.

        Anybody else notice that IE has a slew of undocumented, functional tags? <image> for instance.

        --
        Evan (no reference)

    • I totally agree. Usually if the manual page on the website doesn't answer my question, someone in the comments below has either answered it, or provided a working example, which I guess is probably the same as answering it, or maybe not, or umm..well you get the point.

    • People always talk about how wonderful PHP's online documentation is. Its okay, and the section at the end with the gazillion functions is certainly comprehensive (and reminds me why PHP is not my first choice of programming environments).

      However, I thought this book was *much* more intelligently organized. The section titles made sense. A was followed by B was followed by C. It spoke about good practice and design.

      If this is what most people learned to program PHP with there whould be significantly less horrid PHP in the world. I think this is actually a return to the Oreilly golden era, away from poorly concieved fluff books like Essential Blogging.

      Now if they could come up with a PHP (or Python, or Java) cookbook as good as the Perl cookbook, we would know that the good days were here again.
  • PHP reference (Score:2, Interesting)

    While I am sure that this is an excellent reference for PHP users, I'm sure I'm not the only one who thinks there is little point in buying a book on PHP when http://www.php.net/manual/ exists.
    • Re:PHP reference (Score:3, Insightful)

      by reallocate ( 142797 )
      Bookstores are floating in computer books and many of them are little more than repackaged manuals. The authors add little, if anything, to these books. But, if an author brings experience, perspective, insight and skill to a book, then you'll learn something that's not available elsewhere. If you confine your reading to readme files and syntax manuals, you're limiting yourself.
  • I saw this (Score:4, Informative)

    by asv108 ( 141455 ) <asv AT ivoss DOT com> on Thursday September 12, 2002 @10:24AM (#4244871) Homepage Journal
    The other day while I was waiting for a friend a Barnes and Noble, I picked it up only to put it back on the shelf ten minutes later. Usually I buy every Oreilly book for technologies that I use frequently, but I figured that there is probably very little in the book that PHP's excellent online documentation [php.net] doesn't provide.
    • but I figured that there is probably very little in the book that PHP's excellent online documentation [php.net] doesn't provide.

      I find books generally easier on the eyes than monitors. If I am going to be spending a lot of time with a language, then books make nice additions at times. Plus, you can read the book while waiting for somebody at the airport or the like.

  • I've always found php.net [php.net] to answer all of my questions very effectively. The online manual has everything a manual should, plus additional comments from users. The comments contain everything from hints about how to use a function to complete code samples. Many other programming languages could benefit from similar sites.
  • and help pay Rasmus for his PHP, which is pretty cool. He gave a great tutorial at our university and parked PHP development all over the place. I love Perl like Madonna loves dick, but PHP is a good tool to have in the carpenter's box for many one-off projects and tasks that simply don't require Perl.
  • Tip (Score:4, Informative)

    by Permission Denied ( 551645 ) on Thursday September 12, 2002 @10:32AM (#4244913) Journal
    PHP's online documentation is excellent. Their website has this very useful feature where you don't even have to have a window open to it when you're doing web development: simply type in the name of the function you want:

    www.php.net/mysql_query [php.net]
    www.php.net/strftime [php.net]

    I've found this most useful: you only have to type a few more keys besides the function name to get the documentation, kind of like man pages.

    • If you're running Konqueror, simply type urls of the form php:ob_start. Or, if you're using KDE as a whole, just hit Alt-F2 and type php:print_r or whatever you want. If you need general information (i.e., you don't know the class or function you need), simply do php:xml or php:file uploading.

      --
      Evan (no references)

  • I have also given a 'quickie' review about this book months ago on out little site [signalnine.com]. You can also find the thread on signalnine by clicking on the 'reader reviews' link, on the book information page [oreilly.com].
  • by mgkimsal2 ( 200677 ) on Thursday September 12, 2002 @10:38AM (#4244950) Homepage
    There is no denying that the php.net/manual site is a good comprehensive resource. I do get tired of people suggesting to avoid books and just use the online manual. Obviously, they both have their places.

    The first strike against the online manual is that it's not portable. Downloading in most of the portable formats loses the user contributed comments, which are really what make the online version as helpful as it is in most cases. Seeing how other people have worked around issues, or just posted small extra example snippets is often a lifesaver.

    However, where books can come in useful is the depth. The biggest drawback of MOST PHP books is that they are thin on detail - sometimes a 500 page PHP book has less than 200 pages of 'useful' content, and often times its still elaborated examples of basic 'form submission' code. 200+ pages of reprinting the manual is often not useful for too many people. Yes, it's portable, but I don't need pages of mSQL commands, for example, printed in any book.

    The few good books I've seen regarding PHP that are more in depth and less 'manuals' include the new Professional PHP4 XML (not perfect, but certainly useful if you need to do XML, although that's a moving target in PHP), PHP 4 Web Applications (from New Riders, kinda thin, but many good techniques over and above the usual PHP stuff) and a couple others which escape me. Probably only 20% of the books published actually contain useful stuff you won't find by combing the manual or various discussion boards.

    Also, in defense of books, some people just learn better by being able to read and see examples (which is why the books should have more good examples and fewer filler pages of manual reprinting). Similarly some people do better with hands-on training than with forums or books, which (small plug) my company provides (http://www.tapinternet.com/php/). :)
    • My personal favourite is the Windows help version of the PHP manual which DOES include the user comments if you get the right version. Since there seems to be nearly as much activity surounding the production of this version as there is of PHP itself, it is well worth checking regularly for updated versions. If you're working offline, this is much better than any book can ever be. Like PHP, the Windows help version is wonderfully designed and easy to use.

      Goblin
    • Some people, self included, simply grok things better when they have a book on the desk. Personally, I hate shifting back and forth between the code I'm trying to write, and online documentation. I don't have acres of screen real estate, and I find that it's easier to read a book for long stretches of text anyway.

      I can read a book while I'm sitting on the back balcony, in a relaxed position away from any keyboards (yes, some Slashdot readers do step away from the computing devices from time to time). I can very easily annotate the book with this thing called a highlighter. I can even make notes in it with a special "pen" device.

      Don't give me the expense argument either. Forty or fifty bucks for a good computer book is like an investment in your future employability. For most of us, this book will cost less than we'll bill for an hour or two of work.

      If you don't like computer reference books, that's fine, but realize that for some of us, they're quite handy and worth the money.

      • Not sure if you're replying directly to me or not - I didn't say 'books suck'. Many of the PHP books out there do suck somewhat, because they are mostly reprints of the manual, and reprinting of mostly less-than-useful functions (mSQL, Interbase, etc.). The huge majority are using PHP and MySQL, and even more to the point, often times these books only have examples relating to MySQL anyway, so including 3 pages of info on interbase (manual reprinting) is just filler, making it look like there's more useful info in there than there is.

        I like books - I buy them myself. I just think most of the PHP books out there now are repeating the same stuff. You can get by buying one of them, and essentially have covered 6-7 of them. It's pretty much the same as ASP books or Java books or other languages - there are so many publishers looking to get something out that there a lot of filler and a lot of repetition nowadays - a stark contrast from 1998. :)
  • Being the first edition, it does have some quirks to iron out which I have forwarded to the author. For example, it may talk about one alias to a function but not another, which would be helpful for Perl programmers and the like (for example, split is an alias to explode and join is an alias for implode). There were also a few issues with some of the functions in the book where they mixed up the argument order. Also I felt they didn't put near enough time into optimization, whereas the Perl book spends quite a few pages discussing it (I think the PHP one maybe had one page on it). There were some small things they skipped over which could make a difference in huge projects (when to use "" and when to use '') and whether to do print "$a$b$c" or print $a,$b,$c or print $a.$b.$c, etc. But overall this *is* the best PHP book I have read and I do look forward to their next edition.
  • by Tablizer ( 95088 ) on Thursday September 12, 2002 @11:38AM (#4245391) Journal

    It seems to me that web language books need to be split into two groups:

    1. Web techniques

    2. The language

    Once one is familiar with typical web techniques and issues (form handling, state management issues, etc.), then many of the books seem redundant WRT web techniques.

    The problem is that "Web Programming Techniques" would probably have to choose an actual language for its examples, so they figure they might as well put them together.

    Perhaps Oreilly should split web language books into a language details book, and a "Web Techniques using X" series for those new to web issues (where X is a specific language). They could use pretty much the same material, but simply swap the language for that one.

    Web programming issues are pretty much the same in ASP, PHP, ColdFusion, etc. If I need to pick up yet another web language, such as JSP, I don't want to waste book-size and eye-space on the same web issues, I want to get right into the specifics and uniqueness (gotcha's) of the particular language.
  • I have really limited web experience but I have a simple need.

    Basically, pdf files are generated in a directory. I need a user to be able to see all pdfs in that directory, be able to 'delete' the one he needs after he downloads it, and have the file really be deleted after 48 hours of being marked as for delete

    I have *no* idea how to do this, but what little ive looked at says I need php

    Would php be able to cover all of this, and if yes, would this book tell me how to do this?

    Or should I learn another programing language first?
    • Okay, here's what you want:

      Directory listing.

      Deletion 48 hours after a Delete link is clicked.

      You can do a simple directory listing in PHP quickly and easily(just copy apache's look and feel for directory listings and add a Delete link after each entry). That delete link will be harder. Make the GET string for each delete link unique to the file that will need to be deleted, e.g. delete.php?file=My%20Word%20Doc.doc, etc., and have delete.php write the file name to a text file you'll read with a cron job.

      Now you'll need a cron job to run every hour or half-hour (does the file need to be deleted exactly 48 hours afterward, because that would be harder) and have a perl or shell script read the file names and delete them.

      Hope this helps.
    • Yes, PHP can do this. As others have pointed out, the actual deletions can't be done by PHP by itself and you need to schedule (say) cron-jobs to run the deletion. What the other posters neglect to mention is that you can schedule cron-jobs to run PHP from the command line and do the periodic deletions.

      However, using PHP to do the latter would probably be unnecessary and you could do the same with a shell script. But technically, yes PHP can do everything you want.
    • Use exec() for deleting the files after they have been accessed. Deleting 24 hours later will require some timed event (think cron.) Here you go:

      <?php
      $dh=opendir('/home/');
      while($ file=readdir($dh))
      {
      print"<ahref=$file>". "$file"."</a><br>"."\r";
      }
      closedir($dh);
      ?>
  • As a professional PHP developer, I've found Web Application Development with PHP 4.0 [phpwizard.net] to be one of the best books I've ever purchased. The authors, Tobias Ratschiller and Till Gerken, don't spens time and paper reprinting the manual. instead, they discuss the abstract concepts that distinguish a well-written webapp from a poorly-written one.

    Coding conventions, organizing libraries, API design, and programming in a team environment are all discussed in depth. They include case studies and real-life examples of the concepts they cover.

    To summarize, if you want a great discussion of PHP development that you *can't* get from the online manual, check this one out.

The wages of sin are unreported.

Working...