Become a fan of Slashdot on Facebook

 



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

Learning PHP 5 201

John Suda writes "There are more new books being published about PHP than you can shake a joystick at. PHP (along with program friends - MySQL and Apache) has become very popular among developers and web designers, and for good reason. As a programming language, it is particularly suited to web development projects, while being relatively easy to write, use and learn. More importantly, it's open-source and free, cross-platform, and widely supported. David Sklar's Learning PHP5 is one of the latest volumes dealing with PHP. It describes itself as 'a Pain-Free Introduction to Building Interactive Web Sites,' and provides a gentle introduction to the latest version of PHP, which is version 5 and only recently available." Read on for Suda's review.
Learning PHP 5
author David Sklar
pages 432
publisher O'Reilly
rating 9
reviewer John Suda
ISBN 0596005601
summary An accessible introduction to the popular web scripting language PHP

This book is not particularly useful for those experienced already with PHP, nor for those wanting to upgrade their knowledge of PHP from versions 4 and earlier to the newest version. It's also probably not particularly useful for those power programmers who need and want a deep and comprehensive coverage of the topic. But it is a very well-written and designed introduction to PHP 5 for beginning programmers or those experienced PERL, ASP, or Cold Fusion programmers who want to learn a different language. There are many illustrations and code samples sprinkled throughout the book. Sklar, however, skims over some topics, concentrating instead on practical examples.

The publisher is O'Reilly Media, Inc. which seems to have an editor's policy of covering complex computer-related topics in a comprehensive manner by publishing a range of volumes covering different aspects of a topic or from different angles or for different audiences. O'Reilly also publishes volumes on moving to PHP 5 (Upgrading to PHP 5), detailed and technical PHP (Programming PHP), and a collection of solutions to common PHP programming problems (The PHP Cookbook).

Sklar is an experienced consultant in computer software development and technical training. He is the author of Essential PHP Tools and coauthor of the aforementioned The PHP Cookbook. He takes a deliberate and comprehensive approach to explaining PHP 5, not in great depth, but with the intent of providing enough information, concepts, detail, and scope to create a pleasant and useful read of a technical subject. The basic promise of PHP is in the relatively easy creation of more dynamic and interesting web sites which would include, for example, product catalogs, blogs, photo galleries, event calendars, forms, and more.

There are 13 chapters and 3 appendices. The early chapters provide an orientation to PHP, including its place in contemporary web development, its basic rules, and its syntax. They explain the basic background of PHP and how it interacts with the browser and web server. Later chapters introduce primary concepts like loops, arrays, and functions. The idea here is to facilitate learning the fundamentals of the grammar and vocabulary. Chapters 2 through 12 have short exercises at the end of each to allow the reader to practice writing PHP code and to test learning. (The answers are contained in Appendix C.) Experienced programmers and geeks may recoil at the inclusion of these exercises, but they are useful for beginners.

Chapter 6 provides a practical exercise - how to make and use a web form. The author shows how to access form variables, how to validate user-inputted data for security and efficiency reasons, and how to process forms using functions. Chapter 7 shows how PHP interacts with database programs, like SQL and Oracle, but focuses primarily on MySQL, and demonstrates how to organize data, connect to a server-based database, create tables, and enter and retrieve data.

The rest of the middle chapters cover the use and implementation of cookies and sessions, handling dates and time, and working with files. The practical exercise using dates and times is creating and displaying a monthly calendar. The final chapters provide brief but practical coverage of XML, debugging, and in Chapter 13, other PHP aspects. PHP is amazingly useful, flexible, and practical. One can deal with graphics, PDF documents, and other media like Flash and Shockwave. It also has mailing and file uploading functions, encryption capabilities, and (for more experienced coders) the ability to run shell commands. The upgraded PHP 5 has new capabilities, which now include object-oriented programming.

Appendix A covers installing and configuring PHP for Windows, Mac OS X, and Linux; Appendix B is a short primer on regular expressions and how to use them with PHP.

I found the book to be the most accessible introduction to PHP I have read. It provides the basic fundamentals, engages the reader in practical examples, reinforces learning with exercises, and provides an overall perspective on the scope of PHP programming.


You can purchase Learning PHP 5 from bn.com. (Code examples used in the book can be downloaded at the O'Reilly site for the book, linked above.) 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.

Learning PHP 5

Comments Filter:
  • by prostoalex ( 308614 ) on Thursday October 28, 2004 @05:33PM (#10657929) Homepage Journal
    For the beginners it's worth noting that two PHP books are available for free on the Web (outside of PHP.net documentation).

    A Programmer's Introduction to PHP 4.0 [apress.com] from Apress

    Practical PHP Programming [hudzilla.org] online book

  • by gthumb ( 826174 ) on Thursday October 28, 2004 @05:37PM (#10657968)
    See, this is a book review of a PHP tutorial book. This is not an excuse for the legions of Perl bigots to run out here and start bashing PHP based on outdated versions and foolish generalisations. You say that PHP isn't ready for enterprise-ready applications, but this is a pretty transparent falsehood. There's nothing inherent in a proper installation of mod_php to prevent a site the size of Slashdot or Google from running with PHP instead of Perl or, G-d forbid, ASP.

    You say that PHP's "OOP model" "sucks". First off, the term "OOP model" is frankly idiotic. OOP isn't enough of a coherent programming paradigm to be considered a single "model" or "base". Further, only PHP 4 has inferior OOP features. Why? Simply because they weren't in demand. Most people don't need OOP. It's overengineering overkill for the vast majority of applications.

    It's also been alleged that PHP is somehow slower than Perl or Python for Web. However, Perl and Python all have to be compiled before execution, much the same as PHP. It's well known that PHP compilers and cachers already exist, so there's no reason why running the smallest PHP script shouldn't take any more than perhaps a 1/400 of a second. That's a pretty reasonable time, no?

    PHP is maturing. Its version number is the same as Perl; it's more popular than Perl; it's almost as mature as Perl. It has more users than Perl, more bug fixes being put out, and its few idiosyncrasies are very well known. Frankly, there's fewer traps for a beginning PHP user than a beginning Perl user.
    • Wow, a little bit defensive, are we?
    • by Anonymous Coward
      Its version number is the same as Perl
      Next time you should leave that part out, it's quite irrelevant and completely superficial.
    • Woah silver - Have you LOOKED at PHP5 recently? Inheritence, Overrides, Private Methods and properties, static methods. Looks like a pretty good implementation of OOP.

      And for those zealots who bitch about the fact that everything's a function, dive into Pear...

      The only thing that'll keep php5 from getting into the mainstream is the fact that it doesn't offer too much more other than a much better implementation of OOP, and default installs don't have the mysql package by default - they only have imysql
  • by colin_n ( 50370 ) on Thursday October 28, 2004 @05:38PM (#10657973) Homepage Journal
    PHP4 is to PHP5 as ASP is to ASP.NET? Is that statement correct? What advances does PHP5 make that puts it in direct competition with ASP.NET?
    • by ptlis ( 772434 ) on Thursday October 28, 2004 @05:41PM (#10657992) Homepage
      It runs on something other than IIS...
    • by jbellis ( 142590 ) <jonathan@carnage ... m minus math_god> on Thursday October 28, 2004 @05:43PM (#10658015) Homepage
      ASP.NET is infinitely better designed than classic ASP. (Not perfect by any means -- ASP.NET should be next to "leaky abstraction" in the dictionary -- but they got a LOT right this time around.)

      PHP5 has more features than PHP4 but is aggressively backwards compatible, thus, with a few exceptions it's as crufty as ever.

      I would pick OpenACS [openacs.org] over ASP.NET but I would pick ASP.NET over PHP5 or most J2EE stacks.

      • How aggressively backwards compatible? It has been my understanding that a LOT of stuff written under PHP4 will not work under PHP5 without significant rewrites, and that there are no intentions of adding in that back capability. I have not yet seriously tried using PHP5 as yet largely because of this. Can you clarify?
        • Unless you're using certain quirks of PHP4 (that you shouldn't really use if you're following good coding guidelines) then PHP5 is a dropin replacement for PHP4.

          At work we've moved many complex database driven/CMS sites written in PHP4 to PHP5 with no modifications at all.
        • How aggressively backwards compatible? It has been my understanding that a LOT of stuff written under PHP4 will not work under PHP5 without significant rewrites, and that there are no intentions of adding in that back capability. I have not yet seriously tried using PHP5 as yet largely because of this. Can you clarify?

          You can see Backward Incompatible Changes [php.net] and new keywords [php.net] for the things that may cause problems for you.

          The biggest issues I can forsee is if you currently use some of the new keywords in

      • Parent post might be a bit misinformed. By the way, what does "aggressively backwards compatible" actually mean??

        Anyways, the biggest redesign with PHP5 is its Object-Oriented Model. It now reflects to what a true OO model should be such as Private and Protected Members, Final, Private, Protected and Static Methods, class abstraction, Interfaces and a standardized constructor and destructor syntax.

        The backwards compatibility comes from everything else with PHP. Pretty much all the functions remain intake
    • Absolutely not. ASP is a scripting language. PHP is a scripting language with string OOP features. ASP.net is a framework for the web, which allows you to use a fully featured OOP language such as C#.

      To be honest, if you've never used ASP.net, then it is difficult to explain the differences. But for the web, nothing else comes close.
      • I have used ASP.net and PHP4. I love PHP4 for my personal page and the simple things that I make but for making web pages that feel less like the web and more like a native program, it seems like asp.net has an edge. Does PHP5 attempt to create some of the framework that makes it possible to work with data without page reloads etc... it seems like this is what ASP.net does differently. To me, when I work with some asp.net apps, you load the page once and everything else works in the background without refre
      • Absolutely not. ASP is a scripting language. PHP is a scripting language with string OOP features. ASP.net is a framework for the web, which allows you to use a fully featured OOP language such as C#.

        The original ASP wasn't a language, it was a framework too. You could write ASP pages in vbscript, jscript or even perl.
      • by Anonymous Coward
        ASP is a scripting language. PHP is a scripting language with strong[?] OOP features.

        This implys that ASP did not have OOP features. In fact, J(ava)Script has a powerful 'prototype'-based OO system. Even VBScript has basic OO -- about the same as normal VB.

        (It's funny how ASP got such a bad rap from PHPers, but PHP is just now getting many of the features that ASP had years before it went obsolete.)
    • Objects are no longer called by copying. OObjects are now called by reference.
    • I'll address only your first/second question...
      See Zend PHP 5 press release [zend.com]
      this is what's new in PHP 5...
      Summary:

      Zend Engine II has Object-Oriented development features for component-based enterprise applications

      Extended XML support

      Support for web services

      Enhanced Database support

    • by Ogerman ( 136333 ) on Thursday October 28, 2004 @09:39PM (#10659589)
      What advances does PHP5 make that puts it in direct competition with ASP.NET?

      PHP5 competes with ASP.NET (and Java) up to a certain point. This is a question of best tool for the job. PHP5 is great for developing interactive websites, CMS/forums/blogs, and other lightweight web applications as suitable for an inexpensive hosted environment. However, PHP5 is still way behind today's Java and .NET platforms for developing enterprise (aka. complex, database-heavy) applications -- whether for the web or otherwise. In many cases, PHP is legitimately the "simplest thing that could possibly work" and is thus an excellent choice. However, the architecture that makes PHP great for RAD and simple web applications also severely limits its usefulness for more complex applications. I say this not off-the-cuff but entirely from real-life experience.

      So it comes down to this: if your application is simple enough, by all means use PHP5. It is a great tool for limited-scope jobs (analogous to VisualBasic for the web perhaps) and its performance and scalability is excellent given its limited-by-design architecture. Simplicity on the low end is PHP's strength.. it doesn't try to do too much for those who don't need it to! On the other hand, if your application is more complex (most business apps, anything accounting / finance related, mission critical databases, etc.) use a modern, lightweight, framework-driven Java approach like Spring + Hibernate. PHP is no longer the "simplest thing that could work" when the application domain has moved beyond what it naturally does well. You can force the use of just about any language for any given task but that doesn't mean it makes sense to. (and spare me the silly politics..)

      Choice is good. What does disturb me is how many open source programmers today think that PHP, Perl, and Python are the answer to everything web-related. They're not. I could name a few dozen projects currently using those language that would be far better off using Java instead. Incidentally, Python is the closest to competing directly with Java's domain, but needs a few more years for its tools to mature.

      http://www.extremeprogramming.org/rules/simple.h tm l
      http://www.springframework.org
      • I just want to apply a virtual +1 to this post.

        There is a very subtle line in the sand where PHP becomes 'underkill' and you need to consider moving to a more rounded technology like J2EE or (*spit*) .Net. Experience is knowing where this line is (or better still knowing that the product being developed will cross it in X amount of time).

        There are far too many people using J2EE and .Net style techs for things where PHP would be (and would remain indefinately) the much better choice.

        Also, the other way ar
      • Java's frameworks usually stink anyhow. There is way too much coding for otherwise simple things. It is a beurocrat's dream. What is missing from web developement is the VB/Delphi event-driven model where events and properties are closely associated with UI objects/features and easy-to-get-to (not digging around in code). That is the best model for interactive application design that I have seen, and anything that moves away from that turns into a monster.

        The problem is that no current web frameworks get i
        • Java's frameworks usually stink anyhow. There is way too much coding for otherwise simple things.

          It depends on what your needs are. Some complexity simply cannot be avoided given today's technology. Also, keep in mind that VB/Delphi would also represent "too much coding" if it were not for their RAD GUIs that do a lot of work for you and hide much of the "glue" that holds everything together. On the Java side, you have tools like Eclipse that perform similar functionality, albeit with a bit more develo
    • You can find a job if know ASP.net
  • by dargaud ( 518470 ) <slashdot2@@@gdargaud...net> on Thursday October 28, 2004 @05:43PM (#10658010) Homepage
    I had to use Perl for a project some time back. It was quick and dirty and did the job. At the same time I learned python without managing to apply it to the project. I recognized that I liked python better, but perl was faster to implement.

    Slightly later I did a web project where some interaction was necessary. Instead of my old cgi-scripts or DHTML, I started it in PHP and Zope, as a newbie in both. While recognizing that Zope seems very clean I was totally unable to wrap my head around its basic concepts ('TAL' anyone ?). In one afternoon I had PHP installed and a 140 pages of PHP converted from HTML, up and running. Going from HTML to basic PHP takes about 5 minutes.

    So, while I regret to say that, some languages look cool but others just do the job. PHP is certainly one of the latter.

  • Back in my day... (Score:5, Insightful)

    by sleighb0y ( 141660 ) on Thursday October 28, 2004 @05:45PM (#10658026) Homepage
    We would learn PHP from the php.net documentation alone!

    And we liked it that way!
  • by Anonymous Coward
    As a programming language, it is particularly suited to web development projects, while being relatively easy to write, use and learn. More importantly, it's open-source...

    So, being open-source is more important than suitability to task?
    • by Anonymous Coward
      It is for me.

      If it's open source and clumsy, it will can always evolve into something better. If it isn't, well, they got your money once, and you better be happy.
      • "If it's open source and clumsy, it will can always evolve into something better"

        So you would be happy if your bank lost money from your account due to clumsy free software, just so they could use free software out of principle?

        Right tool for the right job. In some circumstances the development team dont have time to wait for the software to mature, nor do they have the resources to help develop said software. They have to work with something that is mature and stable NOW. If that happens to be commerc
    • So, being open-source is more important than suitability to task?

      For many of us, being Free Software is "suitability to task". That is, non-Free software is an automatic disqualification from the running.

      I've built my company's web apps on Zope, Python, PostgreSQL, and FreeBSD. None of those "vendors" will go out of business next year (but if they did, who cares?). There will be no forced upgrade to a more expensive version that we don't need. We can get timely (and free) security updates and feature upgrades. We have an infinite-user license.

      How on Earth could a closed vendor compete with that? The answer: they can't. There are far too many Free options for developing network applications to even glance at the proprietary stuff.

      Oh, and my boss likes our system so much that he just gave me permission to release all of the non-business-logic software I've written over the last year under an open source license. The only remaining step is to pick the license that we'll use to share our work with the community that made it all possible. Have I mentioned today that I dig my job?

      • You have many insightful points on your post, but I figured I'd field this one:

        How on Earth could a closed vendor compete with that? The answer: they can't.

        oh, I don't know, possibly by providing a product that actually works, and increases productivity, versus an inferior copy-of-features, slightly usable program.

        That is not to say OpenS software is inferior (plenty are amazing--linux,mozilla,openoffice,etc..), just commenting on your seeming blind adoption of it just because it's OpenS.
  • Check out this one [amazon.com] as well. I got them both from the local library (amazing that they had them right away) and Beginning PHP5 was a more complete book. I still liked Learning PHP5, but I felt there were things left out. I know the review says that it doesn't go too deep, but I prefer the practical examples in Beginning PHP5.
  • by EZmagz ( 538905 ) on Thursday October 28, 2004 @05:55PM (#10658109) Homepage
    With a language like PHP that has a very active developer community associated with it, why plop down for a book like this when websites like THIS ONE [php.net] exist and give all the documentation that you'd need when learning the language? I realize that it's handy in having a hardcover book to read (hell, I've got my fair share right next to my unemployed ass) and reference...but still.

    Just curious.

    • php.net is a wonderful reference, even for people who have only the most rudimentary understanding of how to use php but for a total newbie I can see how it could be very daunting; I personally began my way with php scripting by downloading a few pre-made scipts (for an automagically generated image gallery iirc) and realising that none of the three I had grabbed worked and there were features that if worked I would like from each. So I did the obvious thing and (looking up stuff on php.net) cobbled them to
    • We all have different methods or modalities for processing information -- some people get the most from listening to lectures, others from reading, others from doing hands-on, others from dissecting/disassembling things.

      Recently someone observed that I do a lot of handwritten notetaking, highlighting, 'circles 'n arrows.' It made me realize that, for example, I understand code so much better if I print it out, write notes, draw boxes, etc. When I do pseudocode, the ideas flow better if I write by hand, do

  • by Kenja ( 541830 ) on Thursday October 28, 2004 @05:55PM (#10658110)
    The fastest way to learn PHP is to track down David Sklar and eat his brain, thus gaining all his knowledge and abilities.
  • by Anonymous Coward
    There are more new books being published about PHP than you can shake a joystick at.

    Sure you can. I did it just last week. If you want proof, just look at the police report.
  • I read it (Score:5, Informative)

    by Jack9 ( 11421 ) on Thursday October 28, 2004 @05:56PM (#10658119)
    When this PHP book appeared in Border's Books last week I read through it to make sure I was still up to speed. I've been programming PHP since 2.0 (back when you could go on IRC and talk with Lars). The book is mostly a verbose rehash of select bits from the documentation by a collection of authors. Wow, described it in one sentence. Didnt seem to have anything over the documentation on the PHP website.

    The bit on XML was interesting as I've never needed to use XML and now have a single practical example to point at.

    The book is not a 9...more like a 6. It's a professional paperback monolith and it doesnt spread disinformation. I don't know what's wrong with the reviewer *shrug* but this isn't a book I'd recommend.
    • Most people know Rasmus, but he wasnt as available as Lars even back in 1999 :p
    • ...what book would you recommend?
      • Well, just speaking for myself, after throwing together a little mysql/php scheduling calendar for the local elementary school (my fiance is a teacher there) to learn the language, I bought The PHP Anthology.

        If someone where to ask me about learning PHP, I'd tell them to scratch an itch, using php.net, then buy The PHP Anthology [sitepoint.com] from sitepoint. Great stuff. I think it has been reviewed here before but I'm too lazy to look. Anyway, you can download a couple of sample chapters to see if you're interested.
    • As PHP books go, I have "Programing PHP", "Web Database Applications with PHP and MySQL", as well as the "PHP cookbook" If I had to pick one of the 3 it would be the PHP cookbook, its wonderful. It has saved me several hours worth of work. Thought the other 2 are also great as well. The MySQL cookbook is also great.
  • i love php, ive been programming using php for at least 3 years now and no concerns. It rocks as a web dev language and there are so many cool things you can do with it! Even windows programming (GTK :))
  • What's with all the PHP book reviews recently? I seem to recall seeing three reviews within the last several months for various PHP books.

    They must be publishing these things like mad.
  • I like this book, I picked it up the other week as my new job requires me to work with PHP. 90% of my prior work was all in bash with occasional touches of perl or C.

    I don't understand why people are critical of this book. It is basic, yes, but it is targeted for beginners anyhow. Is it comprehensive? No, but then there are hardly any books that are on a given language.

    Hell, even John Carmack bought the "Camel Book" when he needed to learn perl, and as he said, leigons of people would have laughed, or bee
  • Great book, I'm new to dynamic Website creation and the book presents information in such a way I or a more experienced person could both equally understand it. Each chapter has evaluation questions at the end. Good stuff, amazed it made it to /.! Also, the hawk on the book is cool too. =)
  • Job Lobby (Score:2, Insightful)

    by Line_Fault ( 247536 )
    I love PHP5! I've been running it since the first beta!
    Now if only I could find a job writing it!

    It seems most of the jobs here are ASP related mostly because Microsoft actively sells their product, there is no one selling Free alternatives.
    • I found a sweet job programming PHP when all that was listed in the want ads was ASP (which I have zero experience with). Just look up every company in your area that possibly has a web development department, and send them your resume.

      I got hired two weeks after I sent mine in, and I've loved my job ever since.

  • php5 Host ? (Score:1, Informative)

    by Anonymous Coward
    We found a really good php5 host if anybody is looking. These guys seem to know their stuff.

    http://www.a2webhosting.com/ [a2webhosting.com]
  • Comment removed based on user account deletion
  • I was able to attend a "PHP Bootcamp", held by the nice folks at Big Nerd Ranch. David is an able teacher, and I would highly recommend the class to anyone looking to get a leg up on PHP. My only issue was that the book's answers to the chapter excercises were sometimes a bit more complex then they needed to be. More then just answering the question, David models good programming technique, which sometimes made finding the simple answer to "how do I do that?" a bit of a challenge. However, once the answer w
  • ... At Big Nerd Ranch [bignerdranch.com], and it was awesome. If you like the book and you want more personal training, they're talking about doing this PHP5 bootcamp again in about 5 months. It's held at a fantastic retreat setting in georgia, so it's fairly free from distraction. If you've tried to find PHP training, you know this is an unserviced market largely, so if/when they offer this class again, jump on it fast.

    I've been about 3 years into self-taught programming with books, open source examples, and trial and l

  • With all these books popping up people tend to forget that php's main site has a particularly comprehensive manual [php.net] that is also chock full of user contributed notes and code snippits. For the beginners, there is a good tutorial [php.net] there too.
  • More PHP suppliments (Score:3, Informative)

    by kuzb ( 724081 ) on Friday October 29, 2004 @03:18AM (#10661079)
    For those interested, I wrote a PHP manual suppliment called phpbar [nullcreations.net] that works in your browser too.

    Yes, yes, it's a shameless plug, but I had a lot of fun putting it together ;)
  • After developing in asp.net in visual studio, and jsp in eclipse, I couldn't imagine going back to the textpad days. What is available in terms of debuggers for php sites? Are we still depending on echo's?
  • and having coded all my web applications in Perl, until recently, I decided to implement PHP on a fairly lightweight Bookfair system. I built it using a complete OOP framework and it's running amazingly well. As for the overbloated PHP design (twenty functions for the same thing), I hear you. All I can say is keep consistency in your code, limit yourself to a handful of functions. And hope, eventually, PHP will mature even further. Then again, it's mostly about 'how' you code rather than 'what' you use t

Love may laugh at locksmiths, but he has a profound respect for money bags. -- Sidney Paternoster, "The Folly of the Wise"

Working...