Follow Slashdot stories on Twitter

 



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

PHP and MySQL Web Development 223

PHPee writes ""Learn the concepts and build the applications..." - PHP and MySQL Web Development is a well-written web developer's guide to using these open source products to create dynamic websites quickly and easily. This book covers everything you need to design, build and debug your own website from the ground up. Special attention is paid real-world issues, like database normalization and site security. Overall, a great reference for beginner and more advanced programmers alike." Read on for the rest of his review.
PHP and MySQL Web Development
author Luke Welling & Laura Thomson
pages 896
publisher Sams
rating 9/10
reviewer PHPee
ISBN 0672317842
summary From hello world to e-commerce in under 900 pages...

The authors of the book (Luke Welling and Laura Thomson) do a great job of introducing new programmers to the world of PHP and MySQL. The book is divided into five sections which take the beginner programmer through many lessons in solid, secure web programming.

Part One

Starting with the "PHP Crash Course," the reader quickly learns the syntax and language constructs of PHP. The following five chapters focus on topics such as arrays, string manipulation, writing functions and object-oriented PHP. This provides a solid foundation in PHP before moving on to the intricacies of MySQL. This section is very hands-on, using realistic examples, which could be expanded upon as skills progress.

Part Two

The following section focuses on MySQL, starting by explaining the advantages of a relational database vs. a flat file storage system. The book assumes no knowledge of databases, explaining simple terms such as tables, columns, rows, etc. It then progresses on to the fun stuff, like designing databases for the web and normalization.

Particular attention is placed on MySQL's privilege system, including proper use of the GRANT/REVOKE commands to give/take away rights for database users. This section is quite detailed and offers a lot more information than I expected. The various column types and associated keywords are also examined in great detail, providing the reader with a solid understanding of MySQL's main features.

Part Three

Part Three of the book examines the issues associated with running an e-commerce site. This section is nicely done, looking at common mistakes and how to avoid them. These include things like server security, data backups, keeping detailed logs and dealing with other threats, such as crackers, denial of service attacks and destruction of data. Authentication methods and encryption schemes are also thoroughly covered.

Part Four

This section of the book expands on part one, delving into some more advanced PHP techniques, such as interacting with the file system, using network and protocol functions and generating images on the fly with the gd library.

This section also looks at PHP's powerful session functions, including using sessions with authentication and the use of cookies.

Part Five

This is by far the most exciting section of the book. Here the reader is presented with seven real-world examples that utilize most of the issues presented throughout the book. These practical projects are presented in an easy to follow manner. The basic problem is presented, and then a solution is proposed. The authors take you from start to finish, outlining the database design, necessary files and functions and show you how to tie it all together. They are also very good at pointing out possible enhancements or alterations, hopefully inspiring the reader to develop their skills and create something beyond the scope of the book.

The seven projects are as follows:

  • User authentication and personalization
  • Shopping cart
  • Content management system
  • Web-based email service
  • Mailing list manager
  • Web forums
  • Generating personalized documents in PDF format


Each of the projects has a real-life application, and can easily be modified to fit the needs of almost any website. The shopping cart application is quite complete, and could serve as a basic cart as-is. The web-based email service incorporates the IMAP and POP3 protocols in an easy to understand manner. And the web forums project discusses the complexity involved in creating a threaded discussion board. It even refers to slashdot as a "fantastic example of a popular website that uses discussion boards" :)

Other info:

There are a few minor typos and errors in the book, but nothing to get angry at the authors about. Most of them are quite negligible, but may still create some frustration for beginners. (For example, they make reference to a function isempty(), which does not exist in PHP. The real function is simply named empty()...) Small errors like this may create some confusion, but the errata listed on the author's website are quite helpful, yet not all-inclusive.

The appendices do a good job of showing you how to install apache, PHP and MySQL to get up and running under both Linux and Windows. The book also comes with a CD that contains a PDF version of the entire text, all code examples, and copies of PHP and MySQL so you can set up your own development environment at home.

Overall

The book is targeted toward intermediate to advanced programmers, but I'd suspect it would be more useful to the beginner to intermediate group. However, the book is organized in a way that accommodates beginners and more advanced users. If you have previous programming experience, you can probably skip some of the early chapters and jump straight into the larger projects. It's a handy reference book, nonetheless. This book covers almost everything you need to know to learn how to use PHP and MySQL to create dynamic, database-driven websites in no time at all. It does an excellent job presenting some real life projects, and the emphasis on security and clean code is consistent throughout the entire book.


You can purchase PHP and MySQL Web Development 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.

PHP and MySQL Web Development

Comments Filter:
  • mysql.com and php.net are the best reference you can ever get.
    • by Ron Harwood ( 136613 ) <harwoodr@NOSPAm.linux.ca> on Monday January 27, 2003 @01:07PM (#5167996) Homepage Journal
      I will agree to an extent...

      When I am writing a web-app... I will often go to their sites as a reference... however, I find that the examples are sometimes lacking.

      MySQL [mysql.com]'s site is rather poorly laid out and makes assumptions that you already know all there is to know about MySQL - pretty good reference, poor for learning from.

      PHP [php.net]'s website is excellent - again though - not a great learning source... there are user submitted examples - but they aren't moderated or proofread... so are often garbage.

      I think I've learned more about PHP/MySQL from books and PHPBuilder [phpbuilder.com] than I have from the actual PHP/MySQL sites...
      • PHP.net's comments are moderated and proofed. Many developers have access to this; I do.

        S
      • team up and create a single documentation download for developers. Since virtually everyone using the 2 would be running a local webserver - why not offer a download with a MySQL database dump file of the docs, with some PHP pages to use to set it all up and as the search engine to look stuff up? It would surely be easier than having to scroll through pages for that function you've forgotten the name of - or for other functions that may be more appropriate!

        I'm thinking of doing this myself, BTW - pumping all the PHP docs into a db for my own use - maybe the Perl and Java docs too for a single nice web search..
    • for north americans who find www.php.net too slow, there is a faster one at: us2.php.net
  • Excellent Book (Score:5, Informative)

    by lpret ( 570480 ) <lpret42@NOspAm.hotmail.com> on Monday January 27, 2003 @12:51PM (#5167900) Homepage Journal
    I have always been an O'Reilly kind of guy, but I picked this book up and was very impressed. I'm probably catagorised as an intermediate programmer, and I found it intuitive and easy to pick up. Also, the book assumed you had some grasps of the concepts which kept it from being redundant and boring. A very good book if PHP is your second or third language.
  • Apache Fun (Score:5, Funny)

    by Big Mark ( 575945 ) on Monday January 27, 2003 @12:54PM (#5167910)
    "Learn the concepts and build the applications..."
    Then realise, after many sleepless nights of trying to get it to work, that your Apache build is bugged.

    -Mark
  • Old News (Score:3, Informative)

    by Anonymous Coward on Monday January 27, 2003 @12:56PM (#5167921)
    This book has been out for a couple of years now. Don't know why this needs to be posted.
    • You could look at the review as being out of date, as this book was published 2 years ago, but it would be better to think of it as being 2 weeks early, as the second edition is due out soon.

      Here [amazon.com] is the old edition.

      Here [amazon.com] is the new one.

      If you want to build your own URL at a non-patenting bookstore, the ISBNs are 0672317842 (1st ed) and 067232525X (2nd ed).

  • Apparently, a distribution of Linux comes on the CD as well... Here is the book on linux.org [linux.org]
  • I Have This Book (Score:5, Interesting)

    by Acidic_Diarrhea ( 641390 ) on Monday January 27, 2003 @12:57PM (#5167927) Homepage Journal
    I got this book over a year ago and I must say that, while I enjoy it and it is well written, I would agree that it is more for an inexperienced programmer. As someone who knows a bevy of languages, the hand holding wasn't really useful and ultimately if I had a problem with PHP syntax, I didn't go to the book, I went to the PHP docs from php.net. I find the online documentation for PHP is some of the best documentation I've ever seen for a language. I did use the MySQL sections a bit just to check on syntax for MySQL commands, specifically setting up user permissions and such. This was, in part, due to the documentation provided by the MySQL people - which is a bit lacking. But the presentation of the information on MySQL was always set up as sort of a walkthrough of your typical needs. When you need to stray from this, that's when you need to consult other sources OR start guessing. I suppose I could have benefitted more from a book purely on MySQL, use the online PHP docs, and maybe save some money! Oh, one other complaint I had was that they attempted to cover some aspects of SQL but really didn't provide enough of a description to be able to 'know' SQL. And they didn't hit normalization in any effective way whatsoever but, luckily, I already know all I need to know about normalization. I guess to sum up my review: it's a good book if you are implementing something simple and don't already know how to program that well. But if you've got a large-scale LAMP project it might be best to get some standalone reference texts for each. And now, I'll suggest a few:
    Fundamentals of Database Design [amazon.com] is a great book for learning about normalization of a database into any of the many forms.
    MySQL [amazon.com] by Kofler is my favorite book on MySQL.
    As for a pure SQL reference, just go with O'Reilly. Have a great day!
  • Target market (Score:4, Interesting)

    by noz ( 253073 ) on Monday January 27, 2003 @12:58PM (#5167930)
    "Overall, a great reference for beginner and more advanced programmers alike."

    I'm not a big fan of books that are targeted at both beginner and advanced programmers. Authors and publishers attempt to target their product at all available readers, but I find myself skipping chapters in some books (either early or late). What have you found?
    • by Dr. Wu ( 309239 ) on Monday January 27, 2003 @01:30PM (#5168134) Homepage
      And I've been programming since the Pet/Apple ][/Atari days.

      I wanted to make some changes to my website last year to take advantage of a MySQL database. While the O'Reilly Reference at the time got the database configured fine, it was more of an issue of getting the database tied into the website.

      I picked up this book and within four hours it was up and running, and coded near-perfectly on the first run (there were some minor tweaks that need to be made for format).

      While I agree that there are some great resources for PHP and MYSQL on the web, it doesn't exactly lend itself to armchair (or bathroom) reading. The other problem with the web is that I've found it hard to find step-by-step tutorials, versus code that focuses on a specific command or feature. Once you're familiar with a language, those resources are excellent. But when you're just starting to dabble, it's good to have a reference that takes you step-by-step through the process (even if you end up only skimming 75% of it).

      I think the best testimony I can give for this book, is that after using it to get my site up, I lent it to one of the web programmers at the office (and let's just say that my company is a well-recognized name in the computer industry).

      I haven't seen the book for six months.

      Dr. Wu
    • Re:Target market (Score:2, Interesting)

      by hanzwurst ( 547741 )
      I'd completely agree to you. Furthermore, I'll never understand how one can prefer printed documentation in favor of online-documentation. There are some strange people out there ;)

      This book covers almost everything you need to know to learn how to use PHP and MySQL to create dynamic, database-driven websites in no time at all.

      This disqualifies this book for me. In my opinion, there is a lack of books for advanced PHP programmers. You'll find plenty of write-your-own-webshop-in-2-mins-books, but I'd like a book covering security or performance for example. Any suggestions?
      • Re:Target market (Score:2, Informative)

        by Brandon T. ( 167891 )
        Take a look at "Web Application Development with PHP 4.0", by Ratschiller and Gerken. This book is primarily intended for advanced php programmers and contains topics on advanced topics such as bitwise operations for storing values in databases and writing your own database-driven session handlers to replace php's.

        Brandon
  • www.php.net (Score:5, Informative)

    by Anonymous Coward on Monday January 27, 2003 @12:58PM (#5167936)
    To be honest I'm not sure you really need a book to learn PHP or MYSQL, both of these have excellent websites which cover their respective topics extremely well.

    I have bought a few PHP books, the wrong ones I think, and none of them have come close to being as informative or as useful as the website.

    The other thing with PHP is that there are now so many free projects using PHP it is often a lot better to look at they are coded, I think you gain a lot more pratical knowledge this way than you could glean from any book no matter how exhaustive.

    I am of course speaking from the perspective of someone who was familiar with programming and scripting before I came to use PHP but maybe it is better to get a book or learn programming theory before you come to apply it to a language. Although languages are different once you know what you want to do you can usually apply your general knowledge to the language without too much trouble and in the process I think gain new persepectives on what is a right or a wrong way to do something.
    • About php.net (Score:2, Insightful)

      by Fulkkari ( 603331 )

      I have never had any problems with php, because of the excellent, (almost?) clearly written documentation [php.net].

      However what have suprised me on local php developer forums is that people completely new to any kind of programming find the site very technical and difficult to understand. Therefore will they often seek for alternative resources, like books or websites.

      As you mentioned the free php projects, I have to say that I don't think that you can get very much out of those. I find it much better to look at small snippets than large projects, because it's much easier to understand. Especially for beginners.

    • Re:www.php.net (Score:4, Insightful)

      by dboyles ( 65512 ) on Monday January 27, 2003 @03:43PM (#5168827) Homepage
      The other thing with PHP is that there are now so many free projects using PHP it is often a lot better to look at they are coded, I think you gain a lot more pratical knowledge this way than you could glean from any book no matter how exhaustive.

      The only problem I have with this is that sometimes new programmers want to use this copy-and-paste style coding before they really understand the language. I mean, most /. folks know the benefits of reusing code in this way, but doing so without knowing what it's doing is risky business. I don't think I need to explain why.

      For that reason, there certainly is a place for beginner books, as this one seems to be.
  • by gilxa1226 ( 464588 ) on Monday January 27, 2003 @12:58PM (#5167938) Homepage
    This book is great... not only as a beginning to PHP and to mySQL, but also for combining the two into an extremely useful tool. I used the book for an independent study I did my junior year of college, and I still pull it out for references even when PHP is not the language that I'm using to interface with my mySQL server. It is great and easy to read.
  • Phpp (Score:2, Interesting)

    I hardly ever use perl anymore, first of all I find that phphome is amazing, a really great resource, and second, exactly what can you do with perl that you can't do with php??? Third I find it about 3X profitable to just use static pages with some basic markup.

    Now, I'll admit, I used to be rather pro-perl, but as they say, A programmer who's under 30 and uses php has no heart, and a programmer over 30 who doesn't has no brain!
    • That saying is rather interesting - I've never heard it before. I don't really think that I agree with it, though, espescially as Smarty and PEAR start falling into wider use. PHP is really starting to come into its own.
      Why would a younger person being on the cutting edge of a relatively young language be considered not having their heart in the game, but an older one considered dumb for not "getting it" early on?
      Realize that I'm at the upper end of the 30-year-old cutoff, and have a respectable understanding of Perl, PHP, and C...
    • what exactly what can you do with perl that you can't do with php???

      A few examples:

      Parse [cpan.org] and create [cpan.org] binary Excel files, even on Unix?

      Automate [cpan.org] your smart home?

      Configure a linux packet-filtering firewall [cpan.org]?

      Monitor [cpan.org] SNMP devices across the enterprise?

      Perform [cpan.org] various [cpan.org] System Administration [cpan.org] tasks? [cpan.org]

      Program using the Win32 API [cpan.org]?

      Write for extra speed? [cpan.org]

      Write native GUI apps in windows [cpan.org] or unix/linux [cpan.org]?

      There are over 4000 other reasons in the module repository known as CPAN [cpan.org].

      I use several languages, but when I want to be productive, I turn to Perl because of CPAN. Generally, I have 80% of my code nicely abstracted in object-oriented modules. (Note to OO purists: bugger off, we're comparing to PHP not Scheme or Eiffel or whatever)

      • Slight typo above. The second-to-last bullet should read:

        Write modules in C [cpan.org] for extra speed?

      • Your comment isn't entirely fair.

        Sure, you can do all that in Perl, but only because someone has bothered to write the appropriate CPAN modules for you. That's not the same as saying you can't do those things in PHP.

        As PEAR and PECL [php.net] (PHP's answer to CPAN) comes into it's own, I suspect you will see a lot of that functionality get ported over to PHP. Heck, some of what you mention has already been done.

        But to say that PHP is not capable of doing any of those tasks is disingenuous.
        • Your comment isn't entirely fair.

          Sure, you can do all that in Perl, but only because someone has bothered to write the appropriate CPAN modules for you. That's not the same as saying you can't do those things in PHP.


          Ah, but that's my point. What is it you think I like about Perl? The syntax? Um, no. It's the sheer productivity from having a huge, exhaustive list of modules available.

          If PHP or Python had something equivalent to CPAN, I'd probably switch. But doggone it, I'm addicted to being mega-productive.
    • what can you do with perl that you can't do with php

      I was always very pro-Perl, but I find myself using PHP for just about all web scripting now. I still use Perl for command-line stuff though, as I just know it better I guess. However, unless I've missed something, the biggest problem I have with PHP is that you can't run it through suexec (I understand why), so all PHP scripts run as the web server UID. This has often lead to me using a mixture of Perl+PHP (usually Perl scripts running via a cron-job).

      I only use Apache1.3x though, since Apache2+PHP is pretty dire at the moment - so maybe they'll allow some equiv of suexec when Apache2 is ready for use...
  • by tuxlove ( 316502 ) on Monday January 27, 2003 @01:01PM (#5167952)
    PHP is essential, but MySQL is not stable enough for a real 24x7 web service. The lack of stability of /. probably a good example of this point. And my experience at work also bears this out. We're going to greath lengths to replace all MySQL servers with something else which is actually reliable.

    Someone showed me a quote on the web that said something like, "MySQL is quite stable - I'm able to run for 100 days without restarting it!" That's hardly the definition of stable in my book. Unless you're a hobbyist, or have very few servers and can tolerate some unscheduled downtime in your service, there is no place for MySQL in a web service. Especially when you've got dozens, or even hundreds, of SQL servers. It becomes extremely burdensome to keep them all running, and to write software which is tolerant of SQL server downtime.
    • mySQL not ready for prime time?

      Have you checked Yahoo's financial news lately? They are running mySQL for their backend. Sounds like they are pretty happy with it. Oh, and it runs 24x7 also :D

      I believe there was a slashdot article last month which mentioned this also. Very impressive.
    • by bellings ( 137948 ) on Monday January 27, 2003 @01:20PM (#5168058)
      Especially when you've got dozens, or even hundreds, of SQL servers.

      You have hundreds of servers, each running a seperate, individual copy of MySQL, with multiple databases on each?

      If I were you, I wouldn't worry about the uptime of your MySQL instances -- in my experience, that's rarely a problem. I would, however, worry about the intellectual capital you're expending to catalog and manage hundreds, or perhaps thousands, of databases.

      Simply dealing with the administration requests for database permissions and roles must be a full time job for several people. The dozens of people required to understand and manage the schemas for those databases must be a huge drain on your organization.

      I suspect that using Oracle or MS SQL would save your organization literally millions of dollars a year, simply because of the improved management interfaces and flexibility of the databases as a whole.
    • I really don't know what you are talking about - though I concede that MySQL is far from perfect, I have no problems running it 24/7 primetime, and yes, I run it on Linux *and* Solaris. It's uptime is admirable and it is fine for a medium-sized web service.

      Your "there is no place for MySQL in a web service." sounds like simple chest-beating posturing to me.

      We've had more trouble with disk burn-outs, and we've not had very many of those.
    • MySQL is not stable enough for a real 24x7 web service.
      Yahoo [dmreview.com] disagrees [mysql.com].
  • It needs updating (Score:5, Informative)

    by Ian.Waring ( 591380 ) on Monday January 27, 2003 @01:03PM (#5167962) Homepage
    I agree that the book is a good one (and I built my site after reading it). However, it reflects life at the dawn of PHP 4.0, and several things (particularly on PHP now shutting off globals by default, and changes on session control) now lead the user into some frustrating debugging sessions under 4.2.x onwards. At least until the PHP newsgroups and some of the more modern PHP books come to the rescue. I'd add "PHP Cookbook" (O'Reilly), "PHP Developers Cookbook" (SAMS) and "Web Database Applications with PHP and MySQL" (O'Reilly) alongside this book as good supplements to the more dated Welling/Thomson work. At least until they update it...
    • Re:It needs updating (Score:2, Informative)

      by skribble ( 98873 )
      I posted this here as a seperate post, but the Second Edition of this book (PHP and MySQL Web Development) will be showing up in bookstores around mid-February.

      The 2nd edition has been updated to include PHP stuff that was unavailable or unclear in the first edition (register_globals, PEAR, XML, ...)

  • Considering all the work that O'Reilly has already done with educating users on web serving on OS X with Apache, PHP and MySQL already [oreillynet.com], I'm surprised that they wouldn't even bring it up in a supposedly comprehensive beginner/intermediate book. Left hand/right hand, perhaps.
  • by linuxbaby ( 124641 ) on Monday January 27, 2003 @01:06PM (#5167987)
    O'Reilly has a great service called Safari [oreilly.com] where you can read the entire book, searchable and everything, on their website.

    Very handy for cut-and-pasting long chunks of code without having to retype it while reading the page.

    Here's the link to read PHP and MySQL Web Development [oreilly.com] as reviewed here.

    • Safari is a great service if you don't like dead tree versions of stuff.

      But to get this comment back on topic, the review is about a Sams book, not the O'Reilly book on the same topic.

      Picky, picky ,picky.

      • Safari is a cooperative venture between O'Reilly and Pearson (which includes Sams). Safari really isn't O'Reilly's alone (though they do seem to do a better job of advertising it), and this book is available there.
    • Im having huge problems with safari atm, one of their servers that seems to serve my portion of the internet is returning 0 byte replies, basically jsut header information and nothing else. I have emailed them and so far im getting no response. I can use it at work but my traceroutes end up at a totally different server, so im guessing they have round robin servers for different routes to their site.
  • by sunryder ( 192810 ) <nathanlaan@hotmai[ ]om ['l.c' in gap]> on Monday January 27, 2003 @01:11PM (#5168014) Homepage
    I used this book as a secondary reference for a Database course a couple of years ago, and then later for a reference on developing an online MessageBoard using PHP.

    The book is pretty good, but tends to gloss over some of the more technical issues of PHP. In addition, the book tries to cover so much that there are a few parts that are missing some of the more complex details. For example, the section on PHP Session Management was a little too brief for my liking, and ended up being supplemented with material from http://www.php.net [php.net]

    These were are fairly minor issues and the only really *serious* issue I had with the book was the section on MySQL installation. It made the installation look so simple and straightforward, when in fact it was not. I attempted installing MySQL on several different boxes under both Mandrake and Redhat. In the end, the MySQL server was installed on a secondary machine under FreeBSD, where it installed without a hitch.

  • by Dthoma ( 593797 ) on Monday January 27, 2003 @01:19PM (#5168055) Journal
    And so it's very out of date. This may go without saying, but PHP has had a lot of improvements and general tweaks made from then. Some of these tweaks may prove frustrating.

    For example, in php.ini register_globals is now set to 'Off' by default (from 4.2 onwards) instead of 'On' and if the examples in the book assume that it is turned 'On' it means that the code samples in the book will cease to work. (For example, if the book uses '$subject' as opposed to '$_POST["subject"]' they could be in for it.)

    Even assuming that the book doesn't assume that register_globals is on, there's another problem. Being of version 4.0, it won't use the get and post array variables $_GET and $_POST but rather the deprecated $HTTP_GET_VARS and $HTTP_POST_VARS.

    There are other slight differences. For example, PHP 4.0 doesn't have the functions require_once and include_once, which are useful for making sure you don't accidentally include a file more than once (brilliant for avoiding function redeclaration errors) and the output buffering could be messed up by an incorrect setting in the php.ini file (implicit_flush, if you're wondering).

    Plus it doesn't have useful string functions like strcoll and vsprintf).
    • by __past__ ( 542467 ) on Monday January 27, 2003 @04:47PM (#5169266)
      This is not a flaw of the book, but of it's topic. Granted, usually there are good reasons for the incompatible changes beween PHP releases, but it would be nice if the PHP developers could just take some time and try to think about things before they implement it.

      It is nearly impossible to develop a portable PHP application. You never know what features are available in the installation a client uses. I want a stable development platform dammit, if I'd been looking for an mediocre ad-hoc syntax to access a huge and useful, but ever-changing and frequently buggy library, I'd use VB.

  • why php vs. perl? (Score:5, Interesting)

    by b17bmbr ( 608864 ) on Monday January 27, 2003 @01:33PM (#5168157)
    i have been working with perl for a few years. so, a ocuple of months ago, i deccided to venture into php. plus, my school district just installed php onto their IIS (long story, freakin morons...) server. so, since i won't touch asp (whatever bastardized incarnation m$ decides this week) i figured i'd convert alot of our site to php. it has been for the most part fairly easy. but i still use alot of perl. especially for the flat file database stuff (since they won't give us even mysql).

    here's what i discovered:
    • learning php was fairly quick, very similar to perl syntax
    • perl by a mile on regex. especially the default variable kind. php needs @_ and $_ in a big way. or am i missing something? shorter syntax, easier, at least for me.
    • list() is a nice command, but i'll take @_=split(/:/$_/) any time.
    • php is the SSI that perl could have been.

    • my point is this. i use perl to process much on the back end, maybe just 'cause i am so familiar. now, i simply save all my .html as .php. i don't see php as a perl replacement, but rather two complementary technologies. by themselves each is very powerful. but don't let this dissolve into a damn war over which language. use both. my $.02.
    • ...my school district just installed php onto their IIS (long story, freakin morons...) server. so, since i won't touch asp (whatever bastardized incarnation m$ decides this week) i figured i'd convert alot of our site to php.

      Why didn't you just carry on using perl? You can use perl with iis just fine [activestate.com].

      • i do use perl alot. a funny story about this is that when they decided to do their own hosting and switched servers, mid year i might add, they had no idea that they even installed perl. they didn't even know where it was!! i had to google to find out how to access it on iis. (of course, you can access perl from any folder, typical m$ functionality over security. plus, i discovered, accidentaly, perl operates at system level privelges, cgi can read/write anywhere!!) in fact one of the reasons is the lack of database access. it is their server!! so i had to put all the school news, homework, etc., etc., in flat databases. pita really. but anyways...i use perl for lots on the back end.
    • I think you are missing something. How about:

      $array = split(":", $blah);

      or even

      $array = preg_split('/:/', $blah);

      The confusion is only that PHP uses $ for arrays as well as scalars. I.e., you don't have to use list() and name a bunch of variables on the left hand side.
  • Two Things (Score:5, Informative)

    by ziriyab ( 549710 ) on Monday January 27, 2003 @01:39PM (#5168189)
    1. Amazon has it cheaper [amazon.com] than BN [barnesandnoble.com] by $5.00. And they have free shipping (vs. $4.00 min for BN)
    2. The second edition [amazon.com] of the same book is coming in about 3 weeks (Feb 13), so you may want to wait for that.
  • 1. Cars
    2. People
    3. Books on using MySQL with PHP
  • I've never quite understood the attraction of PHP over Perl (using e.g. Mason or Template to get the templating capability). This isn't a troll, this is a real question. What does PHP do better or easier than Perl plus a templating engine?
    • Readibility. There might be more than one way to do it in PHP, but whichever way you pick, it'll be possible for me to read it. I can give my PHP programs to other, less experienced programmers, and they can figure out what's going on.

      With Perl, it's quite easy to write programs with constructs that will completely confuse a non-expert.

    • PHP has a reputation for being "easy", and I guess perl just isn't viewed as sexy by new web developers.

      I use mod_perl with TT2, adding Class::DBI and a few other goodies, I absolutely love it. And yes, I would rather go back to the mind-numbing frustration of Weblogic (not saying anything about J2EE in general here, just Weblogic) than touch PHP... but then, we all have our preferences.

      But no, I don't think the term "easier" applies here.

    • by eddy the lip ( 20794 ) on Monday January 27, 2003 @03:32PM (#5168765)

      This isn't a troll but a real answer. Almost nothing.

      Perl is more concise, has a superior collection of modules, is mature and has a more planned feel (for example, the whole register globals thing, or the changing of global array names in PHP are evidence of this). These things make perl eaiser and mroe productive to work with.

      Other people (not me ;) ) like PHP because they say it has a lower barrier to entry so that less experienced developers can get up to speed faster. There's usually some comment about readability, but I think that's a bit of a red herring. Using Mason or Ax Kit or (insert templating system here) in perl will get you that much beloved separation of code and presentation that PHP tries so hard to discourage.

      And after all that, I use PHP almost exclusively now. The biggest reason is deployment. I work on sites on numerous servers, and I never know where things will live. It got to be too much of a headache making sure the appropriate perl modules (eg, DBI) would be available. My biggest wish for Perl 6 isn't easier to read regexes, it's some kind of SDK system, where sysadmins can install perl with the Web Development SDK, or the what have you.

      sigh. I miss perl.

      • Using Mason or Ax Kit or (insert templating system here) in perl will get you that much beloved separation of code and presentation that PHP tries so hard to discourage.

        http://smarty.php.net/ [php.net]

        PHP's trying to discourage templating?
        • I'm aware that there are templating solutions available for PHP, but the ordinary, default way to do things is to embed PHP code in HTML. This is the way most people learn it, and I'd wager the way most continue to use it, regardless of what templating tools become available. (I know it's the way most scripts I've been called in to fix do it). It's what the language was designed to do.

          I'm not saying that you can't use templates with PHP, I'm saying that the design of the language encourages you to mix your code and HTML into one big soup. Using something like smarty adds a layer of complexity because it presents a different way of doing what the language was originally designed to do, just in a smarter, safer way. Using something like HTML::Template gives you a way of doing something that wasn't present in the language to begin with.

          Which you prefer is to a large extent a matter of philosophy.

          • I'm not saying that you can't use templates with PHP, I'm saying that the design of the language encourages you to mix your code and HTML into one big soup.

            I've seen as many perl scripts embed HTML as I have PHP scripts. Blaming the language for bad programming practice on the part of the people using it is inane.
            • Y'know, I knew when I wrote that, that would be the response. You've missed my point.

              Blaming a language for the shortcomings of it's programmers isn't a valid criticism, but pointing out that a language encourages certain kinds of bad behaviour is entirely relevant. C lends itself to memory leaks, Java lends itself to over-architecting (ok, arguable, but I'm trying to get an idea across here).

              When PHP came around, it said "put <?php and ?> around your PHP and the output will get stuffed into your HTML." That was the whole idea. Templating systems came after to fix that idea. So, yes, the language does encourage mixing code and presentation. You don't have to do it, but it's a valid criticism.

    • rather than the pissing match about perl has this, php that, first, see my earlier post about why php vs. perl

      it's like this. a php page is simply a .html with a .php extension. if you never added on line of php code, and simply changed every .html link to .php, you'd not notice a thing. however, and i'm hardly some php guru, but you can do things like this: (forget all the DB suff, 'cause i do this with the homework pages for my school's website)

      yo have a file, let's call it homework.hw ( a simple text file). i want to put the data on the page. now if i use perl, i have to call a cgi, and have a bunch of prints and maybe a bunch of heredocs, etc. then i have to basically do: open FILE, "homework.hw";while<FILE>;print; okay fine. but, in .php file, which is simply the exact same .html file, i simply use: <?php include "homework.hw";?> and viola. and of course, i use a perl/cgi form to create the homework.hw file. now, you can also create a link to the .php like this:

      a href=index.php?teacher=smith

      anf then the php looks like this:

      <?php
      include "$_GET[teahcer].hw";
      ?>

      bottom line, use what your comfortable with. they are not competing. it's just taht php has some really useful aspects. not to satrt a flame war, but think of it as php->client-side, perl->server-side.

      as i'm in the process of overhauling our school's site, what i like about it is the plugable nature of it. i create a series of modules, and include the in or not. also call them from GET or not. for instance:

      to include a poll, simply do

      <?php
      if($_GET[poll]=="yes"){include "poll.php";}
      ?>

      and the link looks like this:

      a href="index.php?poll=yes&.......

      so, my template is actually a single table, with 3 columns. anyways, it is a powerful tool.
  • Great book (Score:3, Interesting)

    by fbg111 ( 529550 ) on Monday January 27, 2003 @01:59PM (#5168265)
    I was a noob PHP programmer several months ago. With this book combined with the downloadable HTML references at php.org and mysql.net, I learned it in no time. This book makes a great supplement to the official references b/c it provides a plethora of examples that demonstrate how to do certain techniques that are not always readily apparent.
  • The stuff in this book is so simple that php.net and mysql.com would be better resources. I'll tell you what: if you can find me a book that tell me how to do proper database result caching in PHP/MySQL then I'll be impressed.

    As it is now I end up writing a DB caching class for each app I write because I have to customize it so much to get any speed benefit (since you can't do any real caching). One method will not work on another app very well, depending on the number and types of queries.

    IMO, Zend is holding PHP back. By crippling the language it forces you to buy the Zend Performance Suite to get good performance on an enterprise app. Unfortunately, this same crippling also makes making that enterprise app difficult and is why Java is better in the first place.
  • by egg troll ( 515396 ) on Monday January 27, 2003 @02:35PM (#5168446) Homepage Journal
    Recently I've had a chance to do some web design with PHP. Previously I'd used Perl because I'd heard from many people that Perl was the end all and be all of scripting languages for the web. Imagine my suprise to discover that PHP was vastly superior! I know this is a bold statement, but I have solid arguements to support it.

    Before I begin, let me just clarify something. I'm not arguing that PHP is better than Perl in all cases. There is certainly still a use
    for Perl. Also, PHP isn't perfect but it does manage to fix many of the shortcomings I've had with Perl. Here are a few of the things I've
    noticed about PHP. Finally, I'm not the most talented Perl programmer out there. I generally prefer to use the vastly superior Python, but
    can use Perl if I have to.

    * Ease of use. After about a day I had an excellent understanding of both PHP and SQL. I was able to get a stable, useable and presentable
    website up within 24 hours of reading the basics of PHP. Learning Perl took me weeks and I'm still not even as good with it as I am with PHP.
    I would definitely not recommend anyone new to programming begin with Perl.

    * The OO of PHP is excellent. In my experience, it rivals Smalltalk. We all know that Perl's OO still needs work (whether or not OO is all that great is another discussion.) Hopefully Perl will be patched up so it supports such must-have OO features like introspection, reflection, self-replication and ontological data-points.

    * Outstanding database support. PHP supports virtually every DB under the sun (although Berkeley DB is missing, oddly enough.) Perl seems limited to MySQL and PostgreSQL, and its really a kludge for the later. I've heard that this will be fixed in upcoming versions of Perl though.

    * Speed. PHP is one of the fastest languages I've ever used. While it won't be replacing assembly or C, its definitely faster than Perl in almost every case, particularly in regex which has long been Perl's strongest point. I'm sure there are cases where Perl is equal to PHP, but I can't think of any at the moment.

    * Portability. I can take PHP code off my Linux box and plop it onto an IIS server, or even one of those new Macintosh servers and have it
    run without having to change a single line of code. Try doing this with Perl! Its as though it was written in assembly, Perl requires that much rewriting.

    * Graphics. PHP comes with a nice little graphics library. While I wouldn't use its to code the new Doom (VB would be a better choice)
    its adequate for most web pages, and should be considered as a substitute for Flash for certain things. Perl lacks a graphics library of any kind.

    * Data Structures. Under PHP you can create any type of datastructure you need: Linked lists, binary trees, hash tables, queues, inverse
    Reiser-biased recursion trees, etc. Under Perl you're extremely limited in what you can do. This is because Perl isn't OO (so you can't create Node classes, for example, usefull in a linked list) and because it lacks pointers. Some of you may notice that PHP lacks pointers, but look deeper! Behind the scenes, hidden from the user pointers are used. Because of this, PHP can support complex data structures.

    Again this is just my experience. I don't mean to offend any Perl coders because Perl was an excellent language. However, in most cases it may behoove one to write the back end in PHP instead of Perl.

    Thank you and God bless,

    Egg Troll
    • "Recently I've had a chance to do some web design with PHP. Previously I'd used Perl because I'd heard from many people that Perl was the end all and be all of scripting languages for the web. Imagine my suprise to discover that PHP was vastly superior!"

      Using Perl to do Web development is like using a hammer to build a house. I recommend using hammers when building houses, but it's not quite the be-all, end-all tool. Neither is PHP, VB, C#, Java, etc, etc.

      There are Perl-based content management systems like bricolage that do a very nice job of abstracting away the routine tasks of Web development and providing some extra tools that are very useful.

      I also suggest trying PHP as a templating language, while using Perl for the direct server manipulation (e.g. what mod_perl is really useful for) and for large, stand-alone back-end chunks.

      A few of your points:

      "Ease of use" -- You don't discuss ease of use. You discuss time to learn to program in the language. Different. It took me about 2 years to start thinking in Perl. Four years to feel that I understood it deeply enough to call myself an expert. Another 3 to realize I was wrong. :-)

      "The OO of PHP is excellent" -- Don't know anything about PHP's OO model. I do know that Perl doesn't have one. Perl 6 will introduce an OO model. Perl 5 allows you to roll your own. It does have some very nice tools for building an OO model, but that's not the same thing. I see this as a strength long-term (as it allowed Perl's OO usage to mature before being set in concrete), but it is a weakness in current usage.

      "Outstanding database support" -- I don't like to say that Perl "is the best" at anything, but certainly in this department, you're way off the mark. Perl has amazingly well abstracted database support (DBI) for Oracle, Sybase, MySQL, MS SQL, PostgreSQL, DB2 and just about every other relational database known to man. It also has a very nice Web-based abstraction layer over DBI which allows you to hide some of the details in ways that Web developers tend to want.

      "Data Structures" -- The mind boggles. Perl's complex data structures are sufficient to say the very least.

      The rest is mostly misunderstanding and noise.

      Yes, I realize the post I'm responding to was cut-and-paste from someone else's bad post by a self-professed troll, but I really don't like the idea that someone is going to see this and think it's true....
  • Postgres? (Score:3, Interesting)

    by Micah ( 278 ) on Monday January 27, 2003 @02:39PM (#5168465) Homepage Journal
    Seems like there's tons of books on PHP and MySQL. Not to troll, but why doesn't someone release a book on PHP and PostgreSQL? It really is a better database, and does things in a somewhat more standardized way than MySQL.

    Not that I would need such a book (since I already know the combo fairly well), but I'd like to be able to recommend PG to people over MySQL, and some would find a book like this useful.
  • by skribble ( 98873 ) on Monday January 27, 2003 @02:42PM (#5168484) Homepage
    FYI a new Edition of this book which has been updated to include PEAR stuff, XML stuff, and various minor fixes will be in a book store near you around mid-February.

  • MySQL is not a database. A database is a collection of data.

    MySQL is not a full DBMS either, because it leaves things like transaction control to the application unless you take some extra steps (InnoDB).

    MySQL is not relational, SQL violating several relational prescriptions and proscriptions and MySQL not even raising to SQL's already faulty levels.
    • MySQL is not a database. A database is a collection of data.

      Well, that means that Oracle or DB2 or MSSQL or PostGreSQL aren't databases if they have no data in them, and that my even asshole can be a database if I shove a small collection of data up it.

      Say what you want about MySQL. Say it's not a real a DBMS, or impliments or follows SQL correctly. But it's still a god damn database in reality, and according to your own deffinition.

      Oh yeah...Maybe some of us find it easler to start with something less complex. Maybe some of us don't need a fully-fledged DBMS either.

      Sorry for feeding the troll.

      • >
        that means that Oracle or DB2 or MSSQL or PostGreSQL aren't databases if they have no data in them, and that my even asshole can be a database if I shove a small collection of data up it.

        No, that means that a database is not a DBMS, and that a DBMS is not a database. See, a DBMS is a database management system, therefore it cannot be the thing it was created to manage. Similarly, data does not manage itself, but needs a DBMS (or a SysAdmin, operator or whatever else) to do that.

        >
        it's still a god damn database in reality, and according to your own deffinition.

        According to my definition it tries to be a DBMS, but fails for requiring too much of users and programmers. And it fails to be a SQL system too. But it sure can be used to suboptimally access a database.

        • No, that means that a database is not a DBMS, and that a DBMS is not a database. See, a DBMS is a database management system, therefore it cannot be the thing it was created to manage. Similarly, data does not manage itself, but needs a DBMS (or a SysAdmin, operator or whatever else) to do that.

          Ah, slight missunderstanding of deffinitions. In that case, MySQL must also be a DBMS. If it's not, I'd like you to prove me wrong since it's does infact--manage my data for me.
          You could prove to me that it's a very basic or not very good DBMS. But not that it isn't a DBMS at all.

          According to my definition it tries to be a DBMS, but fails for requiring too much of users and programmers. And it fails to be a SQL system too. But it sure can be used to suboptimally access a database.

          How is requiring less requiring to much? Is this some kind of doublethink? I had a quick look over a begginers guide to Oracle and PHP, the amount of code for a connection or query was more complicated than MySQL. Now if the application doesn't need anything more complex than MySQL. What the point in going with anything else?

          Sure, it isn't a real SQL DBMS either. But it still uses a lot of it's language--It supports a subset of MySQL. And like I said before, if that all that's needed, why bother with something else?

          MySQL suits my current projects just fine. And if I ever find I need something more powerfull, then I'll use that.

          • >
            slight missunderstanding of deffinitions

            I would say fundamental, not slight

            >
            If it's not, I'd like you to prove me wrong since it's does infact--manage my data for me.

            You have to do the integrity control, it doesn't yet. It is beginning to with InnoDB, but in a non-integrated, incomplete manner that needs an extra mile from you. So you can say it's not so good as it could be, but I would say it's not the real thing at all. Admittedly, no SQL flavour is or can be perfect, and no implementation of SQL is complete, but there are file access libraries, there are DBMSs, and things in between. MySQL is in between as yet.

            >
            How is requiring less requiring to much? Is this some kind of doublethink? I had a quick look over a begginers guide to Oracle and PHP, the amount of code for a connection or query was more complicated than MySQL. Now if the application doesn't need anything more complex than MySQL. What the point in going with anything else?

            Being scalable, generic, and declarative. MySQL may require less to start, but it sure requires more to develop and to scale.

            If one starts with MySQL, eventually he will discover he needs something better. Then he will have to migrate, and in addition to the migration pain itself he will discover in horror that he could have done in a few declarative SQL integrity constraint lines what took lots of complex, error-prone procedural applicative code when using MySQL.

            Now Oracle and PHP is not a good combination. PHP is not good with databases at all. And Oracle is know to be too complex and not conformant to anything but SQL Entry Level. But at least some of Oracle's complexity comes from it being scalable: you can connect to any account in any instance, but you never need more than a username/password@instance once your tnsnames.ora is set.

            >
            it isn't a real SQL DBMS either. But it still uses a lot of it's language--It supports a subset of MySQL. And like I said before, if that all that's needed, why bother with something else?

            Because something else will require less coding and help you preserve your data integrity better, as well as scaling better.

  • Debugger? (Score:2, Insightful)

    by leed_25 ( 156309 )

    Total-noob> but I'm going to
    Total-noob> go out on a limb here and say
    Total-noob> that PHP doesn't need a
    Total-noob> debugger

    That sounds like something that a sales 'droid
    said to my manager concerning a 4GL back in the
    early '90s. My manager bought it. I have to
    admit that, in the beginning, I was taken in, too;
    but in the end this turned out to be an instance
    of wishful thinking.

    We tried to develop a modest user interface to
    track the flow of materiel through a shipyard in
    this 4GL. Of course, the implementation tuned out
    to be much more intricate in the real world than
    it had seemed to be in the 'blue sky' concept and
    planning meetings.

    End result: the 4GL code was almost impossible to
    maintain. Eventually the project failed --for a
    combination of reasons, to be fair. Here is a
    king of maxim that I took away from it though:

    Every line of code that is ever written will have
    to be

    1-debugged
    2-maintained

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...