Slashdot Mirror


PHP Cookbook

CEHT writes "Like Tony Williams said in his review on PHP and MySQL Web Development: "PHP and MySQL are probably the most pervasive add-ons to Apache web servers across the web". And I agree with him. PHP is a very powerful scripting language, so developers (not just web developers) can do almost anything with it." Read on to see how well CEHT thinks O'Reilly's PHP Cookbook helps you do that almost everything. PHP Cookbook author David Sklar and Adam Trachtenberg pages 608 publisher O'Reilly rating 9 reviewer Edmond Lau ISBN 1565926811 summary Solutions and examples for PHP programmers.

The approach that the authors use in PHP Cookbook is great. Like most computer books, the authors usually include a summary (in sentence forms) to illustrate what the readers will expect in each chapter. Skalar and Trachtenberg take this even further by including some preliminary (code) examples to explain the general ideas behind each chapters. The examples in the book are self-contained. In most cases, I've found examples to exactly fit my needs -- this makes it one of the better reference books.

Each chapter in the book is divided into multiple sections of Problem / Solution / Discussion with a FAQ style. In each case, a simple description of a problem is followed by a PHP script as the solution. But the meat is actually in the discussions: in-depth details are included here, where the authors also include references, extended ideas, and scripts to inform the readers how much more they can do about the issue.

For example, I was going to add a simple script to my website to parse RSS/RDF files from certain news websites (CNN, Slashdot, ...), and use it as my Mozilla homepage. (Who wouldn't?) This script seems to be simple, but I may make a mistake here and there. As reference, I opened up the book to the section "Parsing XML with SAX." Then I realized the authors already had the script to parse RSS/RDF files in the discussion. Bravo!

For myself, the most useful chapters I found are: Web Basics, Forms, Database Access, and XML. There are also good examples in topics such as security, internationalization, and file processing/management. However, this book does not cover the basics of PHP. If you are a good programmer, you should be able to get away with this using the PHP Manual. A good book to learn PHP is Programming PHP, also by O'Reilly.

Although this book covers a wide range of topics, it does not cover topics like generating PDFs. I would also like to see the authors add one (maybe two) case studies in later editions. That would give the reader a more concrete example of how to combine tricks presented by this book. Other than that, at the price of $39.95 (or $61.95 CAD), this book is a great buy!

Topics

  1. Strings
  2. Numbers
  3. Dates and Times
  4. Arrays
  5. Variables
  6. Functions
  7. Classes and Objects
  8. Web Basics - available online as example chapter
  9. Forms
  10. Database Access
  11. Web Automation
  12. XML
  13. Regular Expressions
  14. Encryption and Security
  15. Graphics
  16. Internationalization and Localization
  17. Internet Services
  18. Files
  19. Directories
  20. Client-Side PHP
  21. PEAR

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

238 comments

  1. Best of all by gazbo · · Score: 1

    Linux comes with a php2asp utility, so that you can write scripts in your favorite language, then have it automatically turned into ASP for running on the WinDOS boxes that your boss bought (PHBs just love their FUD ;-)

    1. Re:Best of all by Lordrashmi · · Score: 1

      Or you can just run PHP on IIS.

    2. Re:Best of all by buckminster · · Score: 1

      Or PHP and Apache on Win2k

    3. Re:Best of all by Blob+Pet · · Score: 1

      My web host runs IIS, but I got them to switch me to a server with PHP support quite easily. I felt learning a cross-platform tool instead of ASP was more beneficial for me, since I also have an apache server. Can I do ASP on apache? I'm not sure I care to try to find out. I also found PHP easier to pick up than perl for some odd reason. Then again, if I couldn't read perl in high school, should I be surprised?

      --
      "...today consumers have been conditioned to think of beer when they see a bullfrog..."
    4. Re:Best of all by The+Snowman · · Score: 1

      Can I do ASP on apache?

      Yes.

      --
      24 beers in a case, 24 hours in a day. Coincidence? I think not!
  2. PDFs? by Mr+Guy · · Score: 1, Troll

    it does not cover topics like generating PDFs

    Isn't PDF a closed format? Can you generate a PDF with PHP without also generating an Adobe lawsuit?

    1. Re:PDFs? by Mr+Guy · · Score: 2, Informative

      Also, someone could bring this up, but I'd still like an answer. Isn't PDF owned by Adobe?

    2. Re:PDFs? by Anonymous Coward · · Score: 5, Informative

      From the adobe website:
      "An open file format specification, PDF is available to anyone who wants to develop tools to create, view, or manipulate PDF documents."

    3. Re:PDFs? by Anonymous Coward · · Score: 0

      You can only generate a PDF lawsuit from PHP by using the --lawsuit tag!

    4. Re:PDFs? by Christianfreak · · Score: 1

      PDF is an open format. There are tons of ways to generate a PDF on a unix system.

      *Obligatory PHP flame from the Perl Guy *
      Of course unlike Perl there are no easy/good ways to create one in PHP
      */Obligatory PHP flame from the Perl Guy*

    5. Re:PDFs? by Anonymous Coward · · Score: 3, Informative

      Here's what I use http://www.fpdf.org/ It's a steep learning curve, but it works

    6. Re:PDFs? by GeorgeH · · Score: 1

      Nope, PDFs are an open format. For more information on the subject check out this DevShed article.

      --
      Why can't I moderate something "Wrong" or at least "Grossly Misinformed"?
    7. Re:PDFs? by holovaty · · Score: 3, Informative

      Yes, it's completely possible, as long as your version of PHP has pdflib [http://pdflib.com/] installed as a module or compiled in.

      And, yes, it appears to be legal. (It better be, considering I use it at my job.)

    8. Re:PDFs? by chickerino · · Score: 1

      you can use PDFLib : http://www.pdflib.com/ but it's pretty ugly.

      the nicer solution would be to use XML-FO but I'm not sure what the PHP support is like.

    9. Re:PDFs? by Anonymous Coward · · Score: 0

      Good point, and isn't TXT owned by Microsoft - it is notepad.exe's native file format.

    10. Re:PDFs? by Kamel+Jockey · · Score: 3, Informative

      Can you generate a PDF with PHP without also generating an Adobe lawsuit?

      There's no liability shield built in, but FPDF is a great tool that can generate PDFs using PHP without the need for using a commercially-licensed (read "expensive") PDF generating library. I like it because it is distributed under a BSD-like license.

      --
      In case of fire, do not use elevator. Use water!
    11. Re:PDFs? by raju1kabir · · Score: 1
      Here's what I use http://www.fpdf.org/

      Like the other PHP PDF library mentioned here, it doesn't support CMYK color (only RGB). So you can't use it for printing, only for on-screen use or perhaps for amateur-hour newsletters.

      What's up with that? How hard is it to support a proper color model?

      --
      "Patriotism is your conviction that this country is superior to all other countries because you were born in it." -- GBS
    12. Re:PDFs? by honestpuck · · Score: 1
      Also, someone could bring this up, but I'd still like an answer. Isn't PDF owned by Adobe?
      Well actually, no. PDF is a public domain format. Adobe developed it and has produced the most famous writer of PDF, Acrobat, and the most common reader, Acrobat Reader, but the format is public domain.

      Display PostScript, however, is copyright Adobe and if you use it in a commercial produt you gotta pay them money.

      That's why PDF is used in MacOS X, not Display Postscript. Tony Williams

  3. PHP Security by leeroybrown · · Score: 5, Interesting

    One thing I would like to see more PHP books do is to cover the various Security problems that are prevalent in many PHP based web applications.

    Don't get me wrong, I find PHP to be the best and friendliest solution for many things, but some of the Security problems could easily be avoided with some common sense security advice.

    1. Re:PHP Security by Albert+Pussyjuice · · Score: 4, Interesting
      You are right - there is a general lack of books which deal with writing very fault tolerant and secure PHP code. Most of the PHP books I've seen in the stores start from the basics and focus on getting a database connection up and running and then doing some simple input/output/db access. I think that while PHP has taken off as a web language, this has hindered development a bit because everyone using PHP keeps running into the same problems and has to recode constantly to work around them.

      Of course, writing secure code isn't specific to a language and any book on writing secure code should help to pave the way to avoid common mistakes, just substitute PHP for language X. For instance Writing Secure Code by Michael Howard could be a good companion book to any programmer's library.

      Hopefully, in a few years PHP will have a large enough installed user base (as I think it already does) that the advances issues such as security, tolerance, etc. will be dealt with in entire book(s). Can you tell I am a PHP afficianado?

      --
      DID YOUR MOM SERVE YOU AN EXTRA HELPING OF DUMB TONIGHT?
    2. Re:PHP Security by cyt0plas · · Score: 4, Insightful

      The security problems usually aren't the problems of php, it's the developer's problems. PHP is one of the most newbie friendly web development languages out there. For heaven's sake, it even escapes user inputted strings FOR YOU. That stops most sql exploits, shell string exploits at the door. What happens is that some newbie who hasn't taken the time to read the documentation does something dumb like include($_GET['filename']); While this is a exploitable situation, how many CGIs have been exploited because the author failed to strip/escape user input?

      PHP has a couple of common mistakes, but I'm far more apt to trust an inexperienced PHP programmer over an inexperienced Perl programmer, as far as secure code goes.

      --
      Contact Me (got tired of viruses emailing me).
    3. Re:PHP Security by jpkunst · · Score: 1

      One thing I would like to see more PHP books do is to cover the various Security problems that are prevalent in many PHP based web applications.

      I completely agree with you. David Sklar (one of the authors of the book reviewed here) gave a very interesting presentation about the subject of security in web applications at the International PHP Conference (May 2003) in Amsterdam. You can view the slides of his talk here.

      JP

    4. Re:PHP Security by ikewillis · · Score: 2, Informative
      I'm working on a project that aims to solve the matter of keeping database access passwords secure when using PHP as an Apache module (and consequently all PHP scripts must be readable by a single user)

      It's called phpkeychain and it's modelled after the keychain mechanism in OS X.

    5. Re:PHP Security by Sad+Loser · · Score: 1


      some of the worst problems e.g. register globals on as the default setting has disappeared in the latest versions, but I generally agree.
      I have this book, and it has got some good examples I have been able to adapt and use, but it does need a good understanding of PHP, SQL and HTML to get the most out of it.

      If you want a starter/ reference book, wait a few weeks until PHP5 comes out, and I will be spending my dollars on Leon Atkinson's latest edition in the Core series.

      --
      Humorous signatures are over-rated.
    6. Re:PHP Security by Peter+McC · · Score: 1

      So, in other words, you're saying it'd be nice if the book covered a few security basics, so that developers would be less likely to make those common mistakes. Hmm, sounds familiar.

      I've been looking into PHP, and I love working with it, but I'm still concerned about writing secure scripts. To do a decent job of securing a script, you at least have to worry about several configuration directives, which may or may not be under your control. Basically, I want to see a "PHP Security Best Practices" document, and it's a shame that this book doesn't look like it includes anything on the subject.

      --
      You know what I hate? Wait, what do you like? I hate that!
    7. Re:PHP Security by cyt0plas · · Score: 1

      Security basics aren't that hard, just remember a couple of very simple rules.

      1. If you allow user input, let PHP do it's job and automatically escape it. Don't count on php having magic_quotes_gpc set, simply run "ini_set(magic_quotes_gpc, 1);".

      2. When doing an include() or opening a filename that includes part of a user submitted variable, make sure you clean any user input (check google for examples) user input, to prevent them from specifing a php script by http.

      3. When using forms or cookies, avoid using the generic $variable. Use the specific $_GET['variable'] or $HTTP_GET_VARS['variable'] instead.

      Those simple solutions should stop nearly any common mistake you may make.

      --
      Contact Me (got tired of viruses emailing me).
  4. YES!!! by SuperDuG · · Score: 4, Funny
    Please continue to make these books, I would love to "quit passing on my knowledge" to the morons around me!!

    In all seriousness I enjoy PHP because it is pretty self explanatory, and it can use plain old html inside it too. It's just nice to use a scripting language for the web that was made for webpages originally, not a language that was created for ...

    ... does anyone really know the original intent of perl? I guess that's like trying to find the oringal intent for ducK tape (and no, don't say to seal off ventilation ducts, coz that's what they'd have you believe.)?

    --
    Ignore the "p2p is theft" trolls, they're just uninformed
    1. Re:YES!!! by Anonymous Coward · · Score: 0
      ... does anyone really know the original intent of perl?
      Archaeological investigation into recreating the language of the Old Ones with a view to raising Ktulu from R'yleh and the bringing of the End Times.
    2. Re:YES!!! by Anonymous Coward · · Score: 0
      > ... does anyone really know the original intent of perl?

      Yes, to make doing things that admins did very day easier/automated.

    3. Re:YES!!! by maharg · · Score: 2, Funny

      Practical Extraction and Report Language

      OR

      Pathologically Electic Rubbish Lister

      --

      $ strings FTP.EXE | grep Copyright
      @(#) Copyright (c) 1983 The Regents of the University of California.
    4. Re:YES!!! by Surak · · Score: 4, Informative

      ... does anyone really know the original intent of perl? I guess that's like trying to find the oringal intent for ducK tape (and no, don't say to seal off ventilation ducts, coz that's what they'd have you believe.)?

      Duck tape was invented during WWII by Johnson+Johnson for the purpose keeping water out of ammunition cases -- it was relatively waterproof, hence the reason people in the military started calling it "duck tape."

      You should try watching the History Channel more often. ;)

    5. Re:YES!!! by Christianfreak · · Score: 1

      ... does anyone really know the original intent of perl?

      To manipulate text. Funny since everything is going to a text/XML type of meta format Perl is very well suited to the Web and to system management or for small GUI programs. I think Perl would be a great replacement for say VB.

      *Obligatory PHP flame from the Perl guy*
      of course Perl can do all that and it doesn't need_a_function_for_everything() to accomplish it either.
      */Obligatory PHP flame from the Perl guy*

    6. Re:YES!!! by Mr+Bill · · Score: 1

      Perl has its roots as a tool combining the virtues of sed and awk, and was started mainly as a text parsing/processing language. This is one of the many reasons why it is so good as a web development language.

      What seems to scare people about perl is that there as so many different ways that you can tackle a job like building dynamic web sites. Perl on it's own doesn't forcefeed anything to you, it lets you find your own style. Many people who start with perl will try to do everything from scratch instead of finding one of the many development environments that simplify things for you a clean framework for developing web applications. Some examples are Axkit, HTML::Mason, Template Toolkit, Embperl, Apache::ASP, CGI::Application, Apache::PageKit, and many more.

      Anyway, this article is about PHP, and I won't knock it just because I'm a perl developer. I actually used PHP quite heavily back in 96 when version 2 was just coming out. It was a fantastic tool (even back then) and really let me cut my teeth on dynamic web development. However, I have wandered over to the perl camp, because it is a better tool for me.

    7. Re:YES!!! by SuperDuG · · Score: 1

      Okay I really wasn't expecting a correct answer there. I don't know which is worse, the fact I knew that ... or the fact someone other than me watches the history channel that much.

      --
      Ignore the "p2p is theft" trolls, they're just uninformed
    8. Re:YES!!! by Surak · · Score: 1

      Hey, HC it beats the hell out of the rest of the crap on TV most days of the week. ;)

    9. Re:YES!!! by Photon+Ghoul · · Score: 2, Funny

      of course Perl can do all that and it doesn't need_a_function_for_everything() to accomplish it either

      No, it just needs a module_for_everything.pm :)

    10. Re:YES!!! by Huge+Pi+Removal · · Score: 1

      I thought perl was originally for advanced text processing... I can't imagine trying to write half the basic admin/dogsbody scripts I knock together, for general system maintenance or one-off conversions, with only sh, sed and awk. (Of course, the other half I *did* write with sh, sed and awk, just to keep up the chest-hair/real-man quota :) )

      Anyway, because the brunt of most simple CGI applications is text processing, perl got moved into being used for that.

      --
      - Oliver

      The right to bear arms is only slightly less stupid than the right to arm bears...
    11. Re:YES!!! by JamesOfTheDesert · · Score: 1
      Practical Extraction and Report Language

      A backronym, and not a really good explanation of Perl's reason for being. See here and here for a better background on Perl.

      --

      Java is the blue pill
      Choose the red pill
    12. Re:YES!!! by tha_mink · · Score: 1

      Perl wasn't invented/intended really....it happened as a result of the big explosion at the punctuation factory.

      --
      You'll have that sometimes...
    13. Re:YES!!! by bloodpet · · Score: 1

      You don't need a module_for_everything.pm, The Perl motto is "There's more than one way to do it." The language doesn't force a particular style of programming on you. Write what comes naturally.

      --
      Truth is like a shining mirror that's been shattered.
    14. Re:YES!!! by bheerssen · · Score: 1

      Perl fast facts

      Perl stansds for "Practical Extraction and Reporting Language". Invented in 1987 by Larry Wall, it was originally used for in system maintenance tools for UNIX, mostly parsing logs and foramatting the results for display on the screen.

      --
      (Score: -1, Stupid)
    15. Re:YES!!! by Photon+Ghoul · · Score: 1

      Yes, I know - it was a bit of sarcasm. Anyone that's done anything in perl, knows that it's style is more free-form than that of other languages. I'm not a perl-hater... far from it.

  5. More PHP by betis70 · · Score: 1

    You would think slashdot was written in PHP, considering the amount of coverage it gets in the book reviews.

    --
    I forget...are we at war with Eurasia or East Asia?
    1. Re:More PHP by cyt0plas · · Score: 4, Interesting

      /. itself may not be, but PhpSlash is. Also, I suspect the reason the slashdot crowd likes PHP so much is due to (among other things) a couple of reasons:

      1 - It lets you mix html and code in. Sure, it's not the only language that lets you do it, but it's still a strength.
      2 - It's free, open source (zend crap excluded)
      3 - Microsoft hates it. That's always a plus.
      4 - It's increadibly flexible and forgiving. Coming from a c background, this is one of it's most useful features to me. As far as I can tell, most programmers are inherantly lazy; They don't want to work harder than necessary to do a good job. In PHP, types are incredibly loose. If you want to use a string as a integer, a float, and a string all in the same line, you don't have to cast it. It just does it, and the incredibly vast majority of the time, it does just how you expected it to. Why can't C be that smart?

      --
      Contact Me (got tired of viruses emailing me).
    2. Re:More PHP by Ron+Harwood · · Score: 1

      I'm sure that if PHP had been more mature when /. was created - it would have been considered. If PHP of today were available when Taco was considering it - I'm sure that it would be a different beast today.

      But consider the number of man hours that are in the slash code... it works... it does what they want... and it's in a language that they know well. There's no reason to ever change it.

    3. Re:More PHP by Smidge204 · · Score: 2, Funny

      If you want to use a string as a integer, a float, and a string all in the same line, you don't have to cast it. ... Why can't C be that smart?

      Having a pretty broad background in VisualBasic...

      *puts on asbestos suit and goggles* ...one of the major drawbacks to that is processing overhead. In VB, any variable you don't define is of type "Variant", which is 14 bytes plus the actual data. Ouch. Not to mention the work that has to be done to figure out what the data is and properly deal with it.

      And, of course, making a typo in a variable name can make debugging a real headache. Because you don't have to cast your variables, anything you type is valid, and typos don't generate errors! (You'll always find "Option Explicit" in my VB modules!)

      Having about a month's worth of self-taught PHP behind me, and actually being very comfortable and productive with it, I find that the no-cast variable system works very smoothly. It's a little wierd when it comes to arrays, but good naming conventions help there. It's nice to not have to stop and make a new variable declaration all the time - just code.

      And let's not forget the true power of no-cast variables: obfuscation! He's using it as a flag! No wait.. it's a loop counter! NO! It's an array! AAAHH!! :)
      =Smidge=

    4. Re:More PHP by Tablizer · · Score: 1

      In PHP, types are incredibly loose. If you want to use a string as a integer, a float, and a string all in the same line, you don't have to cast it. It just does it, and the incredibly vast majority of the time, it does just how you expected it to.

      PHP's typing system is kind of annoying IMO. It acts as if it has a hidden "type" attribute for each variable. I prefer languages that don't have this hidden attribute, and more or less store everything as a string. It does require explicit comparison operators that distinquish between numbers and strings, but this is a good thing IMO because it makes it clear what you are intending to compare. Plus, string comparisons are often more complicated than simple equality. Often you want to compare ignoring leading/trailing white space, case, etc. Thus, you need a heavy-duty string compare function anyhow (I write my own when using PHP). Some languages ignore this issue out of some attempt to achieve "proper" operator polymorphism. But it fails with strings and you end up writing your own or doing workarounds anyhow.

    5. Re:More PHP by glwtta · · Score: 1
      It lets you mix html and code in. Sure, it's not the only language that lets you do it, but it's still a strength.

      How on earth is this a strength? This "feature" is probably single handedly responsible for a significant portion of the absolute crap webapp code out there.

      Seriously why would you ever, ever want to mix your code with HTML? That's just so 1990's...

      --
      sic transit gloria mundi
    6. Re:More PHP by Anonymous Coward · · Score: 0

      1 - It lets you mix html and code in. Sure, it's not the only language that lets you do it, but it's still a strength.

      This is most definitely NOT a strength. It will let you do this, just like I will let people hit themselves on the head with a hammer. Neither one is a good idea, but if you want to do it, who am I to stop you.

      Seriously, if you do any serious work with any web language, you'd better start playing with templates, at the very least. I use fasttemplates for php ( tweaked for my tastes ), and I can honestly say I was a retard for doing it any other way before.

    7. Re:More PHP by JavaSavant · · Score: 1

      > It lets you mix html and code in. Sure, it's not the only language that lets you do it, but it's still a strength.

      ARE YOU KIDDING ME?

      This is what drives me batty about PHP as a culture - it takes a great programming language and condones poor if not outright wrong design decisions. The rest of the world is triving towards better design patterns that emphasize the separation of presentation and business logic, and yet PHP programmers still see this as a strength.

      It's a RAD tool at best to be able to do this. If you are in a development environment where PHP and whatever display format you are using is mixed together like peas and carrots, your doubtlessly spend twice as much time fixing your code than you do writing it. In the development environment and real-world applications, templating systems and MVC design are integrally important in the modern web application environment. Look at Struts and ASP.Net for further evidence. The critic will say that evaluation expressions (e.g. ) are neccesary and make your life easier. try writing an application that supports internationalization or user interface customization in PHP using eval expressions, and then write it in ASP.Net or Jakarta Struts....the time and code you save is rediculous...

    8. Re:More PHP by bheerssen · · Score: 1

      At some point, you have to mix your html with code. Even OOP languages have to resort to this at some point. I mean, if you don't, then you must be sending raw html out to the browser without any processing what-so-ever. That is, serving static pages. If you're doing that, you need content management software, not web application software.

      When writing web applications, you should always check for error conditions before writing any HTML to the page. You can do that with any language.

      --
      (Score: -1, Stupid)
    9. Re:More PHP by raju1kabir · · Score: 1
      PHP's typing system is kind of annoying IMO. It acts as if it has a hidden "type" attribute for each variable. I prefer languages that don't have this hidden attribute, and more or less store everything as a string. It does require explicit comparison operators that distinquish between numbers and strings, but this is a good thing IMO because it makes it clear what you are intending to compare. Plus, string comparisons are often more complicated than simple equality. Often you want to compare ignoring leading/trailing white space, case, etc. Thus, you need a heavy-duty string compare function anyhow (I write my own when using PHP). Some languages ignore this issue out of some attempt to achieve "proper" operator polymorphism. But it fails with strings and you end up writing your own or doing workarounds anyhow.

      You can use === to include type when you compare two expressions.

      There are functions that make case-independent comparisons, leading/trailing-space-indepdendent comparisons, and type checks into a few extra characters.

      If you know how it works, it's extremely powerful. If you don't, it generally does the right thing anyway.

      --
      "Patriotism is your conviction that this country is superior to all other countries because you were born in it." -- GBS
    10. Re:More PHP by Tablizer · · Score: 1

      You can use === to include type when you compare two expressions.

      That is super silly IMO. Other scripting languages have done just fine without "hidden types".

      If you know how it works, it's extremely powerful. If you don't, it generally does the right thing anyway.

      "Generally" is not good enough. A 99% conversion rate is not good enough. I agree it might be a subjective decision, but barring better evidence for objective superiority, I do not like hidden types. I do not like them in the rain, not in a train, and not in my brain, Dear Sam-I-Aim.

    11. Re:More PHP by dash2 · · Score: 1

      I ain't sure I buy this. I agree with separating business logic and presentation, but I recently read a very good article on why (PHP's own, but the argument applies to all languages) templating systems suck: essentially, they end up creating their own little language, and forcing the designer to use it.

      I would prefer to have the two layers use the same language. I'm not sure designers ought to be handicapped by the limitations of a templating system - the reason for PHP's success is that lots of HTML designers started using it to write code.

      In any case, I would Just Use Perl given half a chance... here's hoping that Perl 6 gains some ground back, although with operators like ^=~ I have my doubts.

    12. Re:More PHP by raju1kabir · · Score: 2, Funny
      That is super silly IMO. Other scripting languages have done just fine without "hidden types". I do not like hidden types. I do not like them in the rain, not in a train, and not in my brain, Dear Sam-I-Aim.

      Types aren't hidden in PHP
      As anyone can plainly see
      They are not hidden from your code,
      They're right there from the time you load.
      With gettype() they're revealed to you,
      With *val() you can set them too.
      There's so much flexibility
      I can hardly contain my glee.
      Setting, seeing, casting types,
      PHP answers all your gripes.

      --
      "Patriotism is your conviction that this country is superior to all other countries because you were born in it." -- GBS
    13. Re:More PHP by JavaSavant · · Score: 1

      What you are saying is not deniable - Struts has XML/XSLT that is implemented for business logic. Then you have systems like smarty, and ASP.Net is effectively a huge language of it's own (a big one at that). However, I think that it's not a huge tool to add to a designers toolbox to be able to understand some control flow statements at the very least. I have some reservations about ASP.Net being a true division of business and presentation logic with things like datagrid controls built into the ASP.Net control set - but just asking a designer to loop through an array of DTO's using some simple syntax isn't going to break their back. The YAL argument is valid. I'm just not sure that having expression syntax instead of a templating syntax makes the designers life any easier.

    14. Re:More PHP by Tablizer · · Score: 1

      Tell Dr. Suess to take a long long hike,
      for PHP types are not something I really like.
      Don't ask again,
      I won't be in,
      I'm going for a ride on my bike.

    15. Re:More PHP by dash2 · · Score: 1

      It's a tricky one. But in my experience, it is very difficult to have this model whereby the programmer provides all the strings/arrays of strings the designer needs, and s/he puts them neatly into tables. In practice, good design requires careful thinking about data, may require different bits of data than what the programmer originally thought, etc. - and therefore requires close co-operation between designer and programmer. As such, I reckon it is better if they speak the same language, which makes the designer a "first-class citizen" of the process, so to speak. I think the difference between

      $statement;

      and

      <template>

      is fairly superficial - after all, PHP is bigger than cold fusion by miles, mostly on the back of HTML designers who got into it.

      dave

    16. Re:More PHP by cyt0plas · · Score: 1

      I said it's a strength, because some people use it that way. That being said, I _do_ seperate the text and the code, and in fact, most of my pages consist of little more than

      <?php
      include ('includes/common.inc');
      setTheme('themes/mytheme .theme');
      pageHeader('Page Title');
      pageMenu();
      ?>
      Some HTML Here (with openTable(),closeTable(), and other builtin functions thrown in.
      <?php
      pageFooter();
      ?>

      I get very crisp, clean, easy to read pages, that take minutes to write (yeah, I do have to add entries to includes/menu.inc), and output perfect xhtml 1.0 transitional with css2 (excluding bad html in the body). I have over 50 themes I have done that use this system. Just because some people aren't up to doing a large-scale web application doesn't mean they should have to go to a lot of trouble to write trivial things.

      What if someone simply wants the current date and time on their page? Or put the remote IP in a hidden field to read when it's in the google cache. Isn't a little mixing worthwhile when the project is small? That's a strength, not a weakness. People writing bad or ineffecent code is not the fault of PHP.

      --
      Contact Me (got tired of viruses emailing me).
  6. Another book with similar title by bloxnet · · Score: 5, Informative

    Not to be confused with "PHP Developer's Cookbook" (ISBN: 0672323257 - Publisher: Pearson Education) which is a very well regarded reference for PHP. Just wanted to avoid confusion and suggest the book at the same time. There seems to be a flood of PHP/MySQL books out there, or people are just getting around to reviewing them....not sure.

    1. Re:Another book with similar title by goph · · Score: 1

      well ofcourse, since they switched from Perl to PHP they have twice as much time left to write a review!! isn't it fantastic mike?!

    2. Re:Another book with similar title by axxackall · · Score: 1
      There seems to be a flood of PHP/MySQL books out there

      Most of books are for most of peoples. The smarter the subject the fewer people can understand and demand it.

      That's why you see most of books about VB, ASP, JSP, PHP. Less about Perl/CGI. Even less about Python/CGI. Just 2 good (totally 4 found) books about Zope. No books (at least in several stores I've checked) about web-programing with Lisp, Scheme, OCaml or Haskell.

      Well, in the past the reading the hard-printed books was a sign of smart/educated people. Now we are living in the other millenium when:

      • online texts are the only reliabe source about smart and quickly evolving technologies (try to find any books about Gentoo Linux);
      • smart people are capable to find needed info somewhere online, while lazy/stupid people are not capable to find anything on the web and have to go to a book store;
      Conclusion: some day in future we may pro-claim the death of hard-printed books. But we might already pro-claim the death of smart books.
      --

      Less is more !
  7. Student Suspended Over Suspected Use of PHP by Anonymous Coward · · Score: 3, Funny
    Topeka, KS - High school sophomore Brett Tyson was suspended today after teachers learned he may be using PHP.

    "A teacher overheard him say that he was using PHP, and as part of our Zero-Tolerance policy against drug use, he was immediately suspended. No questions asked," said Principal Clyde Thurlow. "We're not quite sure what PHP is, but we suspect it may be a derivative of PCP, or maybe a new designer drug like GHB."

    Parents are frightened by the discovery of this new menace in their children's school, and are demanding the school do something. "We heard that he found out about PHP at school on the internet. There may even be a PHP web ring operating on school grounds," said irate parent Carol Blessing. "School is supposed to be teaching our kids how to read and write. Not about dangerous drugs like PHP."

    In response to parental demands the school has reconfigured its internet WatchDog software to block access to all internet sites mentioning PHP. Officials say this should prevent any other students from falling prey like Brett Tyson did. They have also stepped up locker searches and brought in drug sniffing dogs.

    Interviews with students suggested that PHP use is wide spread around the school, but is particularly concentrated in the geeky nerd population. When contacted by BBspot.com, Brett Tyson said, "I don't know what the hell is going on dude, but this suspension gives me more time for fraggin'. Yee haw!"

    PHP is a hypertext preprocessor, which sounds very dangerous. It is believed that many users started by using Perl and moved on to the more powerful PHP. For more information on how to recognize if your child may be using PHP please visit http://www.php.net.

    1. Re:Student Suspended Over Suspected Use of PHP by Anonymous Coward · · Score: 0

      Feel free to actually link back to bbspot (http://bbspot.com/) next time

    2. Re:Student Suspended Over Suspected Use of PHP by briggsb · · Score: 1

      As the author of the above story, I'd like to collect the karma on this copyright violation. Anonymous Coward please send me 3 karma points plus 3 more for pain and suffering.

  8. Ain't php great? by cyt0plas · · Score: 1

    As a web developer, php has been a real life saver.

    It would take a whole lot of perl code to achieve the same functionality that can be accomplished in 200 well-written php code. (Depending on what it did - it's based off my personal experiences).

    In addition, the ability to mix and match html/php on a cross-platform programming language, as well as write scripts that also run on the command line is worth it's weight in gold (note to people who don't understand that saying, it's really valuable to me). Although perl and cgi scripts can be ran from the command line, they can't have (X)HTML mixed in quite as easily.

    --
    Contact Me (got tired of viruses emailing me).
    1. Re:Ain't php great? by Anonymous Coward · · Score: 0

      In my experience, it takes about 100 lines of perl code to acheive the 200 PHP. But I prefer python anyway...

      Mixing perl+html. Been done. Embperl.

    2. Re:Ain't php great? by Christianfreak · · Score: 2, Informative

      It would take a whole lot of perl code to achieve the same functionality that can be accomplished in 200 well-written php code.

      You obviously don't know Perl, at the very least you don't know about CPAN. How about a decent HTML parser for PHP. XML? How about this: write a program that reads an Excel spreadsheet and uploads its content into a database and let me know how long it takes you in PHP.

      PHP sucks because there is no standard way to extend it, and don't mention PEAR as it so poorly documented its almost completely unusable save for a few of the 'modules' that are there.

      Rather than implement proper namespaces the developers chose to throw everything in the core language. Thus you get a_function_for_everything() which sure makes it easy for the web monkeys to memorize it or look it up but never how or why something works, and in the end you get nothing more than an unmaintainable mess. What happens when a new feature is needed. Re-write city (Yes that is a rant because I've had live in the shadow of my web-monkey predecessor).

      Also what's with mixing data and logic? PHP's whole premise is just plain backwards. Just recently are they trying to bolt on some sort of templating.

      Other problems: no access to the web server, difficult to generate web-server response codes. Errors, including full path-names etc are spit out to the user. (great for security).

      Its been my experience in dealing with both PHP and Perl that proper, templated, documented code takes about the same amount of time and code. And with all the hacks to work around the above problems with PHP, its just easier and more maintainable to use Perl. (Too bad my employers don't see it that way)

    3. Re:Ain't php great? by Mr+Bill · · Score: 3, Informative
      It would take a whole lot of perl code to achieve the same functionality that can be accomplished in 200 well-written php code. (Depending on what it did - it's based off my personal experiences).

      If that is a challenge, then I accept. I can guarantee you that for every command in PHP, there is an equivalent command (or module) in Perl. Hence you should be able to write this imaginary program in exactly the same number of lines...

      Although perl and cgi scripts can be ran from the command line, they can't have (X)HTML mixed in quite as easily.

      Have a look at Embperl, HTML::Mason, Apache::ASP for a couple of examples of how to do this. Most people who knock perl have never discovered the right tools. Personally I would never use those tools, because I am a strong believer in the separation of Code and HTML. I use a templating system for all my projects, and you will never see one HTML tag in my code. Once you work with a team of developers and a separate team of designers you will understand the need for this separation.

      PHP is a great tool! I have used it for several applications in the past (6 or 7 years ago). But if you think that PHP can do more than perl can then you are mistaken...

    4. Re:Ain't php great? by rmstar · · Score: 2, Funny
      For Web stuff I prefer Common Lisp. Better performance, plus it's a language for grownups.

      rmstar

    5. Re:Ain't php great? by czth · · Score: 1

      How about this: write a program that reads an Excel spreadsheet and uploads its content into a database and let me know how long it takes you in PHP.

      Simple:

      <?php
      read_excel_spreadsheet_and_upload_contents_to_mysq l_database_named_foo();
      ?>

      The next version of PHP might be able to do the same for Postgres and Oracle databases and they are considering the ability to be able to upload the contents to tables named "bar" as well (but you may have to buy the Zend engine for that).

      Amen to everything you said (I may add your comment to my page). See also my PHPSucks page. And fortunately my employers do let me use Perl (and C when I think it's justified).

      (Hm, since your nick is "Christianfreak" you probably will know what "amen" means, I guess I can leave it in. :)

      czth

    6. Re:Ain't php great? by raju1kabir · · Score: 2, Insightful
      I can guarantee you that for every command in PHP, there is an equivalent command (or module) in Perl.

      Well, it'll be a module, not a built-in; Perl's built-ins are often powerful in the broad thermonuclear sense, but are never web-specific. Two key differences remain, though.

      One: The Perl modules will have 15 dependencies each, 3 of which are no longer available at CPAN and which have to be hunted down from a Taiwanese mirror using archive.org.

      Two: The various Perl modules you need will use different and incompatible pet data structures as preferred by their various developers, so you'll spend extra time writing glue code - vs PHP where you just use the function and go.

      --
      "Patriotism is your conviction that this country is superior to all other countries because you were born in it." -- GBS
    7. Re:Ain't php great? by bheerssen · · Score: 1

      The one advantage I see to PHP over Perl is persistant session management. To recreate that in perl is quite a bit of work. Even then, in CGI environments it's not a true session, but one that gets reconstructed from files or a database with every page request. At least, that's been my experience. It's very possible that perl has something for that (there's lots of third party modules), but I haven't found it yet.

      For general web stuff, I normally choose PHP because of it's ease of use in most situations. For those that require heavy lifting, like heavy duty parsing of various document types, I use perl.

      Perl is an awesome scripting language - I use it every day for a wide variety of things, but for fast and easy webbased DB apps, PHP is hard to beat.

      --
      (Score: -1, Stupid)
  9. Re:The superiority of PHP over Perl by Anonymous Coward · · Score: 0
    This ended up at troll when it was posted the first time. Whyja think it'd do better today?

    http://books.slashdot.org/comments.pl?sid=57725&ci d=5631859

  10. Buy a Book v.s Web Resources by leeroybrown · · Score: 5, Insightful

    I've been doing PHP web development on and off for a couple of years now and I've always found that it's greatest strength has been the availability of very god online resources.

    PHP.net and many other excellent resources are only a browser click away and remain up to date for free. PHP is one of those areas where I'll save my money and buy a book I'll get genuine reference use from.

    1. Re:Buy a Book v.s Web Resources by elmegil · · Score: 2, Insightful

      Nothing like having half a dozen browser windows/tabs open at the same time, trying to fix/write your web page app. Give me a book any time, realspace makes it a lot more convenient to arrange references around me, IMNSHO. That said, I do appreciate the web references, they're good backfill when nothing else seems to solve the problem. Most of the time. Sometimes googling for answers is like finding a needle in a haystack.

      --
      7 November 2006: The day Americans realized corruption and incompetence weren't addressing 11 September 2001
    2. Re:Buy a Book v.s Web Resources by Azghoul · · Score: 1

      The only trouble I see with the web site and any of these books is that there's never any discussion of "best practices".

      Just because I can easily find a way to do X on the php.net site (which is admittedly where I've learned shitloads), doesn't mean the methods found are any good...

    3. Re:Buy a Book v.s Web Resources by foniksonik · · Score: 1

      Get a good virtual desktop app... problem solved.

      --
      A fool throws a stone into a well and a thousand sages can not remove it.
    4. Re:Buy a Book v.s Web Resources by elmegil · · Score: 1
      um....nope.

      I can still fit more useful content on my desk than I can on a single visible desktop.

      --
      7 November 2006: The day Americans realized corruption and incompetence weren't addressing 11 September 2001
    5. Re:Buy a Book v.s Web Resources by xtrucial · · Score: 1

      ...it's greatest strength has been the availability of very god online resources

      I like PHP as much as the next geek, but I wouldn't ascribe to it god-like powers. :-)

    6. Re:Buy a Book v.s Web Resources by Anonymous Coward · · Score: 0

      easy solution:

      3 monitors.. yes, count em.. there's 3 of them.

  11. No, PDF is open... by SlashChick · · Score: 4, Informative

    The actual document specification for PDF is open. Adobe just happened to not only create the format, but also make the most popular PDF reader and writer (the Acrobat series.) There are, however, free alternatives such as Ghostscript that generate great PDFs from a Postscript file (which you can generate from any program in Windows just by checking the "Print to File" box on a Postscript printer.)

    If you're interested in generating PDFs from PHP, there are a myriad of options available by searching Google. Some web hosting companies also support generating PDFs from PHP, which makes generating PDFs a cinch.

    HTH!

  12. Kiss and say goodbye to Java language!! by Anonymous Coward · · Score: 0, Troll
    No Java, no JSP man. Simply use PHP for web development.
    Forget Java man and go to PHP!

    PHP is 4 times faster than Java technology 'JSP' (Java server pages).

    This tallies because compiled "C" program is 4 times faster than Java.

    Moreover, PHP is getting the object oriented features of Java language.

    The real usefulness of Java is 'Java applets' which run on client browsers but on the server side you simply use PHP.

    PHP is a very lightening fast object oriented scripting language. PHP is 100% written in "C" and there is no virtual machine as in Java. Nothing can beat "C" language ("C" is a language which never dies!!)

    (Java is just another language. The PHP project needs millions of Java programmers who can add the Java's language features like inner classes, static, private, protected and others to PHP. PHP already has some of java' features).
    Java programmers will really "LOVE" PHP as PHP class is identical to Java's class keyword.

    Read the benchmars of Java JSP and PHP. PHP tops in the speed!!

    Read the doc here and mirrors at [1], [2], [3], [4].

    1. Re:Kiss and say goodbye to Java language!! by cyt0plas · · Score: 1

      Then use the Alternative PHP Cache, and get that speed up another 25-400% (depending on the size and complexity of your program. Eat that, java.

      --
      Contact Me (got tired of viruses emailing me).
    2. Re:Kiss and say goodbye to Java language!! by digidave · · Score: 1

      Ever hear of EJBs? Java can beat PHP any day of the week in regards to massive enterprise apps. PHP only really beats Java on its speed of development simplicity of deployment. Those are big enough reasons that PHP is a strong contender for medium-sized web sites and some large sites, but when you need Java's advanced functionality, there's no making PHP work.

      Actually, PHP really needs an app server (ala Websphere) and some sort of Servlet or EJB-like server-side object. The app server could handle database connection pooling properly, caching, application-level opjects, etc. If PHP ever gets to that point, then it will compete with Java on the high-end. Hopefully an improved object model in PHP 5 will start the process.

      --
      The global economy is a great thing until you feel it locally.
    3. Re:Kiss and say goodbye to Java language!! by Decaff · · Score: 1

      Its not just EJBs that make Java a vastly more powerful
      and flexible system for server-side development than PHP.

      With application frameworks such as Struts, you can
      quiclky develop fast and very scaleable applications. The idea
      of embedding both code and HTML in the same file is very
      bad practice, and makes the application both slow and
      inflexible.

      Java (even as JSP) allows use of really high-performance
      and flexible tools such as Java Data Objects to provide
      high-speed object storage even on existing databases.
      (see the Apache DB project for an example).

      PHP is really useful for quick development of small sites,
      but so many IT projects hit problems because small sites
      don't remain small, and need a better solution.

      One great aspect of Java is that you can write re-usable
      code in the form of beans, and use those throughout
      your development environment. You don't end up writing
      something for a web page in PHP and then having to re-invent
      the wheel to use the code in another context.

      Oh, and I find it hard to believe that PHP can match the
      speed of compiled, run-time optimised and native-code
      translated Java/JSP.

    4. Re:Kiss and say goodbye to Java language!! by FyRE666 · · Score: 1

      No Java, no JSP man. Simply use PHP for web development.
      Forget Java man and go to PHP!
      PHP is 4 times faster than Java technology 'JSP' (Java server pages).

      This tallies because compiled "C" program is 4 times faster than Java.

      How on Earth was the above article modded as "interesting"? It's absolute garbage! I use both PHP and Java (and C from time to time) and Mr Coward's "statistics" have zero basis in reality. For one, C is a hell of a lot faster than Java or PHP (unless really really really badly written - like, you'd have to work hard at writing some real crap C code for it to be only 4 times as quick as Java). For another thing, it depends upon the application - Java does have an edge when there's heavy database use, due to it using a pool, rather than PHP's idea of locking a db connection to each httpd child process (which leads to the sight we see rather a lot here, of PHP sites "unable to connect to the database").

      The fact that PHP is a "scripting language" should have clued AC in to the fact it's not actually "C" - it's being interpreted, which doesn't make it anywhere near as fast as C. I love PHP (used to use Perl, but never need to touch it any more - even for shell scripts) but I know it has limitations and is not always the best choice.

    5. Re:Kiss and say goodbye to Java language!! by Decaff · · Score: 1

      For one, C is a hell of a lot faster than Java or PHP (unless really really really badly written - like, you'd have to work hard at writing some real crap C code for it to be only 4 times as quick as Java).

      No its not. It really isn't - and this myth should die.
      Sun's 1.4 Java VM runs Java code at only 10-40% slower than
      the IDENTICAL C code. IBM's 1.4 Java VM can run Java numerica
      code FASTER than the identical C code.

      Don't believe me - try it and see. Just stop spreading
      these myths.

    6. Re:Kiss and say goodbye to Java language!! by FyRE666 · · Score: 1

      No its not. It really isn't - and this myth should die.
      Sun's 1.4 Java VM runs Java code at only 10-40% slower than
      the IDENTICAL C code. IBM's 1.4 Java VM can run Java numerica
      code FASTER than the identical C code.

      Examples???

  13. The Cookbooks are wonderful! by Utoxin · · Score: 2, Insightful

    I've got the Perl cookbook, and have used many of the source code samples found inside in my work. However, most of the development I do is PHP, and I'm extremely excited to hear that they've released a cookbook for PHP. I reccomend this and the Perl cookbook to any developer who wants advice or inspiration.

    --
    Matthew Walker
    http://www.tweeterdiet.com/ - My Diet Tracking Tool
  14. Things PHP is missing by Anonymous Coward · · Score: 4, Insightful

    1) consistant database integration - Why not have a SetDBType() function, rather than hardcoding mysql_connect, mssql_connect, myodbc_connect, pgqsl_connect, etc?

    2) Native XML support - It's just not there? Why re-invent the wheel each time? Give us a good XML tree-walking engine DAMMIT!

    3) sane and consistant functions. Single quotes, double quotes, some functions work with both, some work with one or the other, embedded html in an echo screws up if you don't double quote it, etc.

    4) .NET support?

    In short, PHP is a good language for small projects, but just doesn't cut it in an enterprise setting.

    1. Re:Things PHP is missing by Albert+Pussyjuice · · Score: 1, Interesting

      You bring up some good points but here's a thought I have regarding your first suggestion. Why have a function like SetDBType built in when it can easily be accomplished with a simple include file that specifices the type of database you want to connect to? That way an application only has the database type hardcoded in one place for an entire application. As we can see by C, giving the end programmer a smaller set of tools that always works is better than giving the programmer thousands and thousands of built in functions. I mean, that was the reason for the move to RISC processors after all. Giving everyone these functions that only apply in some situations often just leads to unused functions. Although these types of issues can be more of a problem in a language that is much closer to the hardware.

      --
      DID YOUR MOM SERVE YOU AN EXTRA HELPING OF DUMB TONIGHT?
    2. Re:Things PHP is missing by tkiehne · · Score: 2, Informative

      The PEAR packages, usually bundled with the distribution, would take care of the first two:
      http://pear.php.net/

      --
      -- t_kiehne
    3. Re:Things PHP is missing by weston · · Score: 4, Informative

      1) consistant database integration - Why not have a SetDBType() function, rather than hardcoding mysql_connect, mssql_connect, myodbc_connect, pgqsl_connect, etc?

      I believe there is a PEAR package that abstracts an OO layer over the functions to various databases. Think DBI for PHP.

      2) Native XML support - It's just not there? Why re-invent the wheel each time? Give us a good XML tree-walking engine DAMMIT!

      Natvie XML support is there. A SAX parser is usually built in by default. I'm happily using a DOM XML interface that I compiled into my version.

      3) sane and consistant functions. Single quotes, double quotes, some functions work with both, some work with one or the other, embedded html in an echo screws up if you don't double quote it, etc.

      Quotes in PHP do work in a sane and consistent way, very similar to the way they work in PERL. The only thing I mourn is the lack of a qq[-like facility (and I wouldn't be surprised if someone snuck it in while I wasn't looking, and I just didn't know about it).

      4) .NET support?

      Um.... why?

    4. Re:Things PHP is missing by Angry+White+Guy · · Score: 2, Informative

      It's also on the query side as well. How many people have written wrapper classes to deal with different databases?

      As a side effect, implementing one database call, even with a db_type parameter in the database calls, gives a certain level of abstraction which would allow for greater cross portability. It also helps with application debugging, generating the error closer to the actual failure point, rather than in the wrapper class itself.

      --
      You think that I'm crazy, you should see this guy!
    5. Re:Things PHP is missing by Gaza · · Score: 1

      For the consistant database integration, take a look at the Pear Database class that is included in every PHP download. http://pear.php.net/manual/en/package.database.php

      They abstract out all the database related functions, and are a pleasure to use.

    6. Re:Things PHP is missing by joeldg · · Score: 1

      dude..
      native XML support, it is enabled by default. (see http://us4.php.net/manual/en/ref.xml.php)
      .NET is really only useful/meaningful in MS licenced environment.
      If you want database integration, there are 50 packages you can download (not including PEAR) which can handle all of that for you.
      consistent functions? give me a break. single/double quotes? if you having problems with those in php then you have a long way to go before using the language for anything practical.
      Granted, I have seen some (array functions in php) which could use a little bit of work on getting them more consistent, but overall things are worlds ahead of asp (which I can say as I used to actually be an asp developer, three years ago before I discovered php and switched everything to linux)

    7. Re:Things PHP is missing by Tablizer · · Score: 1

      [Why not have a SetDBType() function, rather than hardcoding mysql_connect, mssql_connect, myodbc_connect, pgqsl_connect, etc?] I believe there is a PEAR package that abstracts an OO layer over the functions...

      I simply wrap the database API functions behind vendor-neutral functions. No need for the additional syntax of OOP. Rarely is more than one brand of database used at the same time, and if there is, use a named parameter to select the vendor. Except PHP does not have named parameters. Rats!

    8. Re:Things PHP is missing by barnaclebarnes · · Score: 1
      1) consistant database integration - Why not have a SetDBType() function, rather than hardcoding mysql_connect, mssql_connect, myodbc_connect, pgqsl_connect, etc?

      Try ADOdb. It is a database access library for PHP which seems to work well.

      --
      [Please type your sig here.]
    9. Re:Things PHP is missing by onash · · Score: 1

      hardcoded functions like myslq_connect and writing my own XML parser was exactly what i didn't like in php when i wrote a website in php few months ago. I also had troubles using OO programming techniques, and trying to use the MVC programming model. Most of the php articles i read were explaining how to do very basic things, and I felt like many of the authors had never tried a real programming language like C++ and therefore had no understanding of what was happening under the "hood". I've used mod_perl, ASP and Java for web-programming, and just didn't fall in love with PHP like i was suppose to. And what surprised me most was that i wrote it all on a Windows machine using php/apache/mysql and it ran fine, but when it was moved to a Linux web server it didn't run! even though it had the same version of php

    10. Re:Things PHP is missing by TheTomcat · · Score: 1


      1) consistant database integration - Why not have a SetDBType() function, rather than hardcoding mysql_connect, mssql_connect, myodbc_connect, pgqsl_connect, etc?

      Because different databases do different things, and abstracting degrades performance -- you CAN, however use ODBC with PHP. I do abstract whenever time allows. Manual abstraction is easy. There's a DB:: class in PEAR as well as ADOdb.


      2) Native XML support - It's just not there? Why re-invent the wheel each time? Give us a good XML tree-walking engine DAMMIT!


      php.net/xml


      3) sane and consistant functions. Single quotes, double quotes, some functions work with both, some work with one or the other, embedded html in an echo screws up if you don't double quote it, etc.


      Quotes always work consistently. If you're thinking of Magic Quotes, it's a "feature" put there to make newbies not do stupid things. It can be turned off, and worked around very easily. I will, however, give you that function naming could use an overhaul, but in order to save backwards compatibility, this has not been done. The parameter order of implode vs. substr is confusing, and easy to forget.


      4) .NET support?

      This might not be exactly what you're looking for, but the January issue of PHP Architect has an article on using PHP with the .NET framework.

      Enjoy. PHP is not all things, but it does a GOOD job on the web.

      S

    11. Re:Things PHP is missing by JavaSavant · · Score: 1

      Actually, I think more important than any of these things is namespaces for packages. Very frustrating to have libraries that are named the same but do two totally separate things. Every other 4GL and 5GL language has this (Perl even has it). Why can't PHP?

    12. Re:Things PHP is missing by ProfKyne · · Score: 1

      Quotes in PHP do work in a sane and consistent way, very similar to the way they work in PERL. The only thing I mourn is the lack of a qq[-like facility (and I wouldn't be surprised if someone snuck it in while I wasn't looking, and I just didn't know about it).

      Not yet, AFAIK, but you can always use the heredoc syntax to achieve the same effect -- the only problem is that the heredoc terminators kind of disturb your indentation. Still very useful for large string literals....

      --
      "First you gotta do the truffle shuffle."
    13. Re:Things PHP is missing by Anonymous Coward · · Score: 0
      There are legitimate criticisms of PHP, but these aren't them.

      Right on!

      The real problem with php is that it's a heap of bull dung.

  15. php, replaces perl for me. by joeldg · · Score: 1

    I use it for just about everything these days over perl. Spam filters, graphing, smtp server, ncurses frontends for apps, fractals, you name it. I also post a lot of what I do in it on my site: http://lucifer.intercosmos.net/

  16. Sick and tired of this by aardwolf204 · · Score: 2, Insightful


    I'm a PHP/MySQL junkie, and every time I see anything about PHP on /. its a damn book review. I know the dynamic duo (php/mysql) are the hottest things to hit the net since <blink> but could we get some more interesting new on php, how about something on php-gtk, or the various other php related projects.
    </rant>

    --
    Im dreaming ofa big bndwdth, That can resist the /.crowd.May ur days b merry & bright & may al
    1. Re:Sick and tired of this by joeldg · · Score: 1

      you could (see /. navigation) "submit story" on something (i.e PHP/GTK) or write an article about PHP5 implementation and new features and submit it..
      I helped out on the PHP-ncurses stuff (see zend.com in tutorials) and submitted that, but it was rejected.. I believe it was passed over in favor of a PHP book review (professional PHP or whatever).. but worth a shot.

    2. Re:Sick and tired of this by Anonymous Coward · · Score: 1, Informative

      I've never read a decent book on PHP, tho the manual is superb for basic stuff. I also want a book that covers things not so well documented online, that I'd otherwise have to grep the source files to learn. MCAL, MCRYPT, Berkley DB extensions etc are not covered well in the online manual. Yeah some advanced GD, curses and PHP-Gtk stuff would rock too.

    3. Re:Sick and tired of this by Anonymous Coward · · Score: 0

      I'm a PHP/MySQL junkie, and every time I see anything about PHP on /. its a damn book review

      maybe because there's nothing newsworthy about PHP. It's "C-like" syntax is the same Achilles heel that Perl has. It's mixing HTML and code is the same Achilles heel that ASP has (the lack of separation between code and presentation is a system architect's nightmare).

      PHP Coders love to talk about how great their language is. But their valid arguments (i.e. the ones that don't involve idiotic misconceptions about Perl) boil down to:

      1. It's easy to learn
      2. It's easy to learn
      3. It's easy to learn

      You know what? There's something to be said about ease of use. But that and that alone doesn't make a language great.

      What we need is a language that includes all the best features of current languages *and* is easy to use.

      All current languages suck. That's why we need so many. Each has a strength. That's about it. End of rant.

  17. Come on now.... by botzi · · Score: 0

    ...we all know the real reason a lot of people prefer PHP over Perl;o))))))

    --
    1. No sig. 2. ???? 3. Profit!!!
    1. Re:Come on now.... by joeldg · · Score: 1

      okay okay.. you got me.. (and yea, that was my background image for a while... mmmm background image)

  18. Good learning tool by mni12 · · Score: 2, Insightful

    I actually bought a copy of this book, as well as the other one referenced in this review. I found them quite useful in learning PHP - the examples can be easily tweaked to create useful little applications. I haven't done very much with web programming except for few CGI-scripts and PHP definitely looks much easier way to create useful applications.

    The examples of integrating to MySQL were especially useful as I have been playing with Microsoft Access using MySQL as server, and now I can easily create web views from the database!

  19. Hmm by JanusFury · · Score: 1

    What I want to know is if there's any way to do any sort of Reflection in PHP. I'd buy this book if it had anything on that subject. JSP, ASP.net, and ASP all have Reflection or at least some features similar to it, but PHP seems to have nothing of the type... and there are some types of code that are next to impossible to write without Reflection - things like XML serialization/deserialization in particular are a pain without it.

    --
    using namespace slashdot;
    troll::post();
    1. Re:Hmm by waynetv · · Score: 2, Informative

      PHP has reflection...

      An entire chapter in the manual for it.

  20. The perfect companion for this book... by jpkunst · · Score: 3, Informative

    ... is (IMHO) the MySQL Cookbook. The 'Cookbook'-format (specific real-world problems and possible solutions) makes for extremely useful books.

    JP

    1. Re:The perfect companion for this book... by MattRog · · Score: 2, Funny

      Because, as we all know, the cookbook approach is the best way to go. :P

      --

      Thanks,
      --
      Matt
  21. Re:PHP most pervasive? PERL by cyt0plas · · Score: 1

    function usual_slashdot_activity () {
    while ($phpzealots == "annoyed") {
    utter($meaningless_nonsense);
    }
    }

    That wasn't so hard, was it?

    --
    Contact Me (got tired of viruses emailing me).
  22. Speaking of FUD by poptones · · Score: 0, Flamebait
    ASP is not a language. PHP is a language (I'm being generous here). BASIC is a language. Java is a language. Javascript is a language.

    Speaking as someone who has worked with both, php2asp is about as useful as those "pascal2c" tools that were so common a decade ago. It works in only the simplest of cases, and rarely supports the internal objects supported by most ASP languages (ie vbscript and jscript).

    PHP blows chunks. It's too bad such a shitty little "language" has taken on such proportion simply because it was, for a while, the only "better" alternative on linux/apache to perl (an even shittier, even more cryptic little language).

    Since the "language of browsers" is ECMAscript it makes sense to use that on the server, too, so one doesn't have to constantly shift back and forth between languages. And one doesn't HAVE to use an MS product in order to do so. It's really too bad so many otherwise intelligent folk abide the braindead notion that ECMA(java)script = ASP = MS.

    1. Re:Speaking of FUD by lamz · · Score: 2, Insightful

      Since the "language of browsers" is ECMAscript it makes sense to use that on the server, too, so one doesn't have to constantly shift back and forth between languages.

      That doesn't even remotely make sense. Most browsers have javascript built-in, so that should decide what language to use server-side? Personally, keeping javascript for client-side and PHP or whatever for server-side is less confusing. That contextual switch is easier when the client-side / server-side code looks different.

      Now I'm off to find a review of a Javascript book, so that I can insert random comments about what a shitty little language it is. That will be quite helpful for someone who wants a book about Javascript, I'm sure.

      --

      Mike van Lammeren
      It will challenge your head, your brain, and your mind.

    2. Re:Speaking of FUD by runderwo · · Score: 2, Informative
      ASP is not a language. PHP is a language (I'm being generous here).
      PHP actually is not a language. PHP is an engine for embedded scripting languages in markup documents. Zend is the scripting language that most people generalize as "PHP", but any other scripting language could also be developed and used with the PHP engine.

      Remember, PHP is to ASP as Zend is to VBScript.

    3. Re:Speaking of FUD by Publicus · · Score: 4, Insightful

      So what are you saying is better than PHP? Running ASP with Javascript (or ECMAscript to be pedantic)?

      If you can tell me that handling forms and working with databases can be done better with something other than PHP please do.

      Also, please tell us what is a 'bigger' language, if PHP and *gasp* Perl are so little?

      I wonder because I started in ASP with VBScript. I learned Perl and PHP and now I do PHP pretty much full time. If I want a script that is blantent CGI I use Perl. To me PHP and Perl completely blow away (not blow chunks) ASP with VBScript -- they are far better languages for web development. I can't say exactly why I think that, but one of the main things for me is the quality of the community surrounding the language. There's a lot more user support for PHP and Perl which to me is more helpful than the MSDN library will ever be. I also like a lot of punctuation -- but that's just a personal preference.

      As far as switching back and forth between languages (JavaScript and PHP, for example), I never thought it was so silly. To me, doing things client-side is distinctly different from doing things server-side. It's no problem to have different languages for those two things. Especially when have to limit what you do on the client side because every browser is different. It seems to me like wasted effort to spend to much time on JavaScript stuff, because lo and behold browser X won't support what I'm trying to do. If I do it server side in PHP, I have an easier time writing portable code.

      You certainly have a right to advocate your language of choice, and probably a right to bash others, but could you explain yourself a little better?

      --

      My Karma was at 49, then they switched to words. All that work for nothing!

    4. Re:Speaking of FUD by lamz · · Score: 4, Informative

      PHP actually is not a language. PHP is an engine for embedded scripting languages in markup documents. Zend is the scripting language that most people generalize as "PHP", but any other scripting language could also be developed and used with the PHP engine.

      You have that ass-backwards. PHP is the language, Zend, the engine. Any other scripting language could be developed and used with the Zend engine.

      --

      Mike van Lammeren
      It will challenge your head, your brain, and your mind.

    5. Re:Speaking of FUD by lamz · · Score: 1

      I wonder because I started in ASP with VBScript. I learned Perl and PHP and now I do PHP pretty much full time.

      I followed pretty much the same path as you, and once I tried PHP there was no turning back, especially once I discoverd the Smarty Template Engine. Everyone doing PHP development should check it out.

      --

      Mike van Lammeren
      It will challenge your head, your brain, and your mind.

    6. Re:Speaking of FUD by poptones · · Score: 1

      I gotta remember to read all the replies before adding mine...

    7. Re:Speaking of FUD by poptones · · Score: 1
      Why are the server and the client "separate?" They are separate physical entities, but when one is making an app it's all one unit; the browser is the GUI, the server the "hard stuff inside." Do you write command line apps in c and then write the desktop interface in pascal? Isn't that the discongruous approach taken by MS in so many VB interface/c backend applications that typically fall under so much distrespect here?

      You seem to have missed it before so I'll say it again: you do not need MS in order to use javascript (and even ASP) on the server. And even on my worse day I would not defend VBscript - nor is ASP vbscript, so it doesn't matter. Saying "ASP sucks" is absolutely NOT the same as saying "vbscript sucks" - and vice versa.

      PHP has a lot of user developed modules, but it still lacks a lot of the things provided right OOTB with MS ASP (or chilisoft with java). Using java alone will also get you that same power and more, but php on a good day doesn't come close to either even WITH all those widgets.

      And if you want docs there are easily as many "javascript toolbox" sites as there are PHP - probably more, in fact, since it IS supported by MS in ASP and most of that code can be used in apache just as well. Honestly, the only thing I can see going for PHP is it's free - and in this case the "free" solution well proves that old adage about getting what you pay for.

    8. Re:Speaking of FUD by eddy+the+lip · · Score: 1

      This is going to sound like such a flame, but it's not, honest. What's the benefit of using something like Smarty over just not putting anything besides control flow or variable output in your HTML files? I keep all the real work in a separate file, and never have anything more interesting than for(;;){ foo } in the file with the HTML. And no HTML in the code file, ever. It's always seemed like another layer of complexity (and overhead) for very little return.

      Or am I missing something?

      --

      This is the voice of World Control. I bring you Peace.

    9. Re:Speaking of FUD by skribble · · Score: 1
      Since the "language of browsers" is ECMAscript it makes sense to use that on the server, too, so one doesn't have to constantly shift back and forth between languages. And one doesn't HAVE to use an MS product in order to do so. It's really too bad so many otherwise intelligent folk abide the braindead notion that ECMA(java)script = ASP = MS.

      Don't usually respond to flambait, but this last paragraph is quite interesting. It seem's that history would suggest that this is not true. Back in it's glory years Netscape thought the same thing about JavaScript. They called it LIveScript/LiveConnect/LiveWire... whatever (They changed it's name in the tradtional MS fashion of changing names of a technology and pretending it's new until it finally catches on (i.e. DOM, COM, ActiveX, .NET...)). Netscape did server side JavaScript better then anyone, and it flopped (well it's actually around somewhere in the Sun's portfolio). It flopped because JavaScript (or whatever you want to call it) *is* an awful language to work in, and people would rather use any of the much better alternatives (which for better or worse often ment Java)

      What was really interesting about what Netscape did was the ability to use the JavaScript on the client side to intereact with the JavaScript on the server side. This is similar to what MS can do with .NET, but Netscape was more or less platform agnostic where MS certainly isn't.

      FWIW WebObjects also originally used JavaScript on the server side, and while it may still remain (backwards compatibility) it was quickly replaced with Java as the prefered language (well... actually Obj-C is and was the prefered language, but it's looks far to wierd for most people to bother learning, which is too bad 'cuz it rocks!)

      --
      --- Nothing To See Here ---
    10. Re:Speaking of FUD by poptones · · Score: 1
      History would suggest what isn't true? That it's easy to flow from client to server when it's all the same language? That most people don't think of vbscript and MS when they think of ASP?

      Netscape's "solution" was proprietary and costly. They were in the wrong place at the wrong time with the wrong solution; apache was catching on quite well when they were trying to sell kilobuck server "solutions" and balkanize the web - and the geeks who spoke "web" back then (ie you couldn't walk down the street and shout to find a "web developer") spoke perl and cgi. Given the choice of supporting open and community supported vs. expensive and supporting the company that is trying to "own the internet" who would you expect to win that battle?

    11. Re:Speaking of FUD by Lordrashmi · · Score: 1

      The reason for a templating solution like smarty is to keep presentation seperate from all the business logic. It also allows designers who only know HTML to change the template. If you keep all the real work in another file, then you are on the right road. However, I have gotten severe migraines from looking at old code that mixes HTML and another language.

      Some template solutions are not much better then mixing PHP and HTML but others like Smarty are kick ass. In Smarty, you can put simple presentation logic in your templates. For example, with a proper template, you just pass an array to smarty and it will render it into a nice table, highlighting every other row, bolding keywords you tell it too, etc etc.

      It does take a little while to get used too, but follow the link in the grandparent and read up on it. It is worth the time I think.

    12. Re:Speaking of FUD by bloodpet · · Score: 1

      The server and client are separate because processes really does run separately. It would matter what would run server-side and client-side because of the web server and browser, respectively. You're probably right that the only thing going for PHP is because it's free. However, you also left out the fact that it's open source, which means that, in time, improvements on PHP will overtake that of other languages'.

      --
      Truth is like a shining mirror that's been shattered.
    13. Re:Speaking of FUD by Anonymous Coward · · Score: 0

      I can name one right off the top my head, Macromedia ColdFusion.

      ColdFusion beats the crap of PHP, ASP and PERL in 2 MAJOR areas, error handling and database queries.

      Try developing on a MSSQL database with PHP, ASP or PERL and then using an Oracle database in the production enviroment. I have seen this one too many times in my web career. With CF I is a matter of changes 3 variables to accomplish the port. With PHP, ASP and PERL you either have to change a dozen or so functions or classes to accomplish the task.

      Let's not forget that with one simple tag placed in the application.cfm, I can catch any error that bubbles up on my website, then have that error email me, allowing the user to only see an error page that I designed telling them that the error is being looked at. PHP, ASP and PERL throws the error to the webpage that the user sees. What great security that is!

      Forget PHP, ASP and PERL. They are immature languages that lack the basics in making up a powerful language.

    14. Re:Speaking of FUD by ProfKyne · · Score: 1

      Mod parent up!

      --
      "First you gotta do the truffle shuffle."
    15. Re:Speaking of FUD by asdfghjklqwertyuiop · · Score: 1

      Try developing on a MSSQL database with PHP, ASP or PERL and then using an Oracle database in the production enviroment. I have seen this one too many times in my web career. With CF I is a matter of changes 3 variables to accomplish the port. With PHP, ASP and PERL you either have to change a dozen or so functions or classes to accomplish the task.

      I can do that with my perl-based sites too. I change the DBI connect string in my PerlHandler, and voila, it works on all the pages.

      Let's not forget that with one simple tag placed in the application.cfm, I can catch any error that bubbles up on my website, then have that error email me, allowing the user to only see an error page that I designed telling them that the error is being looked at. PHP, ASP and PERL throws the error to the webpage that the user sees. What great security that is!

      That's not true either. You can catch exceptions in perl with eval and report them anyway you want. I already do this with one of my sites. I can even set it up so that when you're logged in as a certain user (developer), it will send the error message to the browser and if you're logged in as anyone else it will log the error and tell the user it has been reported.

    16. Re:Speaking of FUD by runderwo · · Score: 1

      You're right, of course. I like dyxlesia!

    17. Re:Speaking of FUD by pacman+on+prozac · · Score: 1

      Smarty takes it far too far.

      It integrates far too much in a templating engine.

      Of course thats just my opinion.......namely that to load one or more html template/s and perform simple pattern replacing on it should NOT require loading a 2500+ line .php file.

      Whats the point of seperating the presentation logic from the main functions if you end up with a presentation layer that is 3x the size of the main program and contains twice as many functions. You lose all the benefits of templating in the first place. Especially when u have to load up a honking great class everytime to use it. As for smarty using basic presentation logic, whats the PHP doing then, just loading smarty?

      I appreciate smarty has nice functions but most of them are for coders not designers, and coders don't tend to be the ones building the templates..

    18. Re:Speaking of FUD by Lordrashmi · · Score: 1

      The point of seperating the presentation logic from the main program even though it might be 3x as big is still maintability. You should never have to go in and modify the Smarty classes. You will however have to go in and modify your own code. To me it is just calling another library for use. I don't know about you, but most of my pages are only a couple hundred lines at the most, but almost all call on some massive libraries. If I didn't want to load the libraries every time, I could hardcode some of the logic into my page, but that would increase maintanence time.

      Anyways, I just got in so this post might not make sense, but even though Smarty is huge, I think what you gain in maintanability is worth it. I wonder if it would be possible to create a "Smarty Lite" with only the basic features?

    19. Re:Speaking of FUD by Anonymous Coward · · Score: 0

      Cold fusion blows chunks.

      It doesn't even have a test for NULL returns from a database query, how can you honestly consider it to be superior to PHP?

  23. News? Publish date = Nov 2002 by walterbyrd · · Score: 2, Insightful

    This book has been out for nearly a year. Is this news?

    1. Re:News? Publish date = Nov 2002 by stephens_domain · · Score: 1

      Um, no. It's not. It's a book review, hence the topic "Book Reviews:"

      --

      ..
    2. Re:News? Publish date = Nov 2002 by Anonymous Coward · · Score: 0

      This book has been out for nearly a year

      Nice of you to round up by adding another 5 months - it's only frickin' June for heaven sake!

  24. Re:Enough MySQL by Kz · · Score: 2, Informative

    Because it's easy, fast, and 'real' enough for the vast majority of quick webpages.

    just like PHP

    if you want a big, complex, very scalable website; it might be better to go with java, for everything else (>90% of cases, i'm sure) it's easier to do it with PHP.

    just the same; if you want a heavy duty database, with lots of concurrent updates, and/or triggers, stored procedures and so... well you can do it with Postgres or mortgage your house and use Oracle. for everything else, it's easier, quicker; and usually faster to use MySQL

    --
    -Kz-
  25. Excellent book, I heartily recommend it to any... by Naum · · Score: 3, Informative
    ...PHP developer.

    Relevant, real-life useful examples are given and even a seasoned pro like me picked up a few gems like the example user authentication code that utilizes a hash instead of having to go back to the database on each page fetch.

    My bookshelves are full of PHP books but most of them are inferior to the online documentation at php.net. They add nothing and are a true waste of trees. This one, however, does not fall into that category.

    --

    AZspot
  26. Wrong.... by botzi · · Score: 0
    I suspect the reason the slashdot crowd likes PHP so much is due to.........

    No!No!No!....
    One last time :
    *The* reason
    ;o))))))

    --
    1. No sig. 2. ???? 3. Profit!!!
  27. All PDF generators suck by Black+Perl · · Score: 2, Insightful

    *Obligatory PHP flame from the Perl Guy *
    Of course unlike Perl there are no easy/good ways to create one in PHP
    */Obligatory PHP flame from the Perl Guy*


    There are no good ways to create one in any language. Current solutions are either:

    (1) A thin shell over text and graphics primitives

    or (2) dependent on an external rendering engine which creates another format like Postscript.

    I'd like a high-level PDF creation library that would let me, say, directly create a table that is sized to fit the contents like HTML, but unlike HTML, will split the table across multiple pages, repeating header and footer information. Sounds straightforward, right? Not possible now. I've checked with Adobe engineers, and it's not even possible with their $20K PDF generation toolkit.

    I can just hear the XSL-FO people saying, "but it IS possible with XSL-FO." And it's also possible, given all the sand and steel you could possibly need, to build a window. Point is, it's currently way too much trouble. I'm sure it'll get there eventually, but PDF creation is really an idea in its infancy right now.

    --
    bp
    1. Re:All PDF generators suck by larry+bagina · · Score: 1
      Have you tried looking into tex/latex? You can convert dvi files
      into pdf files (either with dvips + ghostscript, or dvipdfm), and latex long-format tables allow you to set up headers and footers for tables that extend over multiple pages.


      I think latex tables are ugly to produce in a text editor (html tables seem more intuitive to me), but you can use lyx or gnumeric to do the hardwork. Maybe I should search for an html to latex table convertor some day...


      PS - \usepackage{ae} or the fonts will look like ass. And I don't mean Natalie Portman ass.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    2. Re:All PDF generators suck by Black+Perl · · Score: 1

      Have you tried looking into tex/latex? You can convert dvi files
      into pdf files


      No, I haven't. While that falls squarely into category (2), I may give it a try as a temporary workaround until a decent native PDF generator is available.

      --
      bp
    3. Re:All PDF generators suck by raju1kabir · · Score: 1
      Have you tried looking into tex/latex?

      Anything but the simplest layout is impossible in Latex. It's fabulous for writing your dissertation in 1987, but for modern stuff it breaks down quickly.

      Try doing a typical magazine-style layout with two stories (a main story and a sidebar) each breaking from page 1 to page 2.

      --
      "Patriotism is your conviction that this country is superior to all other countries because you were born in it." -- GBS
    4. Re:All PDF generators suck by Anonymous Coward · · Score: 0
      Anything but the simplest layout is impossible in Latex. It's fabulous for writing your dissertation in 1987, but for modern stuff it breaks down quickly.

      I think you mean 1897.

  28. Re:The superiority of PHP over Perl by lamz · · Score: 3, Informative

    Amen!

    I did a lot of Perl development before switching to PHP, and some of the things you mention that are missing from Perl are readily available as modules from CPAN. But that just adds another point in PHP's favour -- the default install comes with all the stuff you mentioned.

    Before anyone gets their Perl backs up, let me point out why a good default install is important for web development: you don't always have control over the server, so you can't always get the Perl modules you want. (But if you want to re-write your code, sometimes, you'll get what you need! (Couldn't resist.))

    --

    Mike van Lammeren
    It will challenge your head, your brain, and your mind.

  29. .NET support in PHP. Why? by torpor · · Score: 0

    Because the poster is an M$ Troll, of course...

    There is no good reason for PHP to support .NET other than to be qualified for "embracing" and "extending'"...

    PHP/MySQL and Apache is what .NET is designed to get rid of...

    --
    ; -- the corruption of government starts with its secrets. a truly free people keep no secrets. --
  30. You aren't looking in the right places. by SlashChick · · Score: 1

    I'm pretty sure this is a troll (I mean, .NET support?), but since it's had a large amount of "Insightful" mods, I figured I would point out at least one misconception.

    The parent poster complains about "consistant (sp) database integration" as one of the main problems with PHP. This is usually a problem noted only by those who haven't used PHP in serious development. Sure, if you're writing a 20-line script that you know is only going to use MySQL, then who cares what database connection statements you're using. However, if you're writing anything that needs to be more serious and portable, check out one of PHP's database abstraction libraries: ADOdb or Pear DB. Both of these libraries will let you abstract out database functions so that they aren't tied to one specific database.

    Personally, I prefer ADOdb. Not only is it faster than Pear DB, but there's also a C port to speed it up even more. ADOdb also has more capabilities, and its author hangs out in their forums and is extremely helpful with user questions.

    You have to change your mindset a bit to code with ADOdb or Pear DB, but it's worth the bit of extra learning curve to gain portability. Since ADOdb can generate insert/update SQL and also generate HTML tables, I find that I'm faster coding with it than I ever was with mysql_query()... and I can switch to Postgres or Microsoft SQL Server at any time without really thinking about my database code.

    I hope this helps those of you who are still stuck with mysql_query() or similar. <plug>Also, we're a web hosting company that supports PHP 4.3.x, ADOdb and Pear DB, and we will answer your PHP questions as part of your web hosting package.</plug>

    1. Re:You aren't looking in the right places. by joeldg · · Score: 1

      given the benchmarks at http://phplens.com/lens/adodb/ straight mysql is still faster.
      though I can see this as a boon to developers coming the microsoft side of things and trying to get asp code ported to php.

  31. I'd give anything by digidave · · Score: 2, Insightful

    to see a book that deals with advanced application design in PHP. The problem with PHP is that most PHP developers are amateurs who don't know the first thing about app design. At best, apps are written with objects used randomly to accomplish some tasks and mostly include files for 2 dozen reused functions (or functions that aren't even reused, but still included in every page).

    At worst, every database connection is hard-coded in a different place and there are no comments anywhere.

    In either case, my God help anyone who wants to add functionality. These same people need a good book on relational database design, or be subjected to 4 years of universigy RDBMS design courses like I was. IMO, if you aren't willing to slit your wrists to get out of an RDBMS design class, you haven't taken enough of them.

    --
    The global economy is a great thing until you feel it locally.
    1. Re:I'd give anything by Anonymous Coward · · Score: 0

      I agree on some of what you said but comments slow down the scripts, I only comment if something is not immediately obvious. Look at Pear for a way to not comment PHP!

      (I just wrote a Pear style class but the lameness filter didn't like it - good to see it doing it's job!)

    2. Re:I'd give anything by digidave · · Score: 1

      Any of the free PHP accelerators will stop comments from slowing down the script. IMO, the accelerator functionality should be standard. It probably would be if Zend wasn't trying to make money by selling theirs. There'd also be application-level objects and variables if it wouldn't give PHP the ability to cache objects accross sessions, meaning that a developer could get enough speed increase from caching that Zend Accelerator wouldn't be needed.

      --
      The global economy is a great thing until you feel it locally.
  32. Original Purpose by Anonymous Coward · · Score: 0

    Original purpose of duck tape: sealing amo cases in WWII. Check out www.straightdope.com for the details.

    1. Re:Original Purpose by Anonymous Coward · · Score: 0

      > what was the original purpose of anal beads?

      Torture. After awhile though, the Spanish Inquisitors realized they got better results with large, jagged beads than with smooth, comfortably-sized beads.

      How far we've come, from a device of torture to a source of pleasure for millions!

  33. cool by poptones · · Score: 1
    So why do even the PHP people generically refer to it as a language?

    Can I get an ECMA engine for it?

  34. 'web apps' by Kunta+Kinte · · Score: 2, Insightful
    One thing I would like to see more PHP books do is to cover the various Security problems that are prevalent in many PHP based web applications.

    I think a large part of the problem is that PHP is illsuited for many of the larger web applications it is being used for. Traditional Application Server features such as tag libraries found in JSP, ColdFusion, etc. would be good for separating the 'coders' from the 'presentation designers' in large projects, but that's not pertinent to security.

    What gets large PHP web applications like web based mail user agents, like Squirrelmail, and content management systems like PHPNuke is that they have to keep a lot of temporary resources between user actions in a single session. Resources such as open files, sockets, variables in memory, for instance.

    PHP's simple engine, and its lack of language features to support these features forces PHP web application developers to build and destroy many of those resources in the life-cycle of the script instead of the life cycle of the application or the user session that is more appropriate.

    The larger the application gets, the more difficult it gets to build using the simple 'web scripts' programming paradigm PHP and Perl pushes developers towards. This affects security and performance.

    The end result is heavy dependence on databases for variable persistance and error-prone algorithm concoctions, a la PHPNuke et. al.

    --
    Based on upvotes, Ageism is the only "-ism" Slashdotters care about and think isn't SJW
    1. Re:'web apps' by The+Snowman · · Score: 1

      The end result is heavy dependence on databases for variable persistance and error-prone algorithm concoctions, a la PHPNuke et. al.

      Sessions make this process a lot easier and better.

      --
      24 beers in a case, 24 hours in a day. Coincidence? I think not!
    2. Re:'web apps' by Anthony+Boyd · · Score: 1
      The end result is heavy dependence on databases for variable persistance and error-prone algorithm concoctions, a la PHPNuke et. al.

      Yes, but PHP has sessions. At my work, we use the session features to do variable persistance. What am I missing? I'm sure I've failed to grasp the crux of your argument.

    3. Re:'web apps' by Kunta+Kinte · · Score: 1
      Yes, but PHP has sessions. At my work, we use the session features to do variable persistance. What am I missing? I'm sure I've failed to grasp the crux of your argument.

      Sessions, according to PHP can't store resources bound to the server, eg. open sockets, because the session isn't bound to a single server instance but many resources are, at the OS level( please correct me if I'm wrong, that functionality would help me optimize much of my PHP code ).

      So for the mail user agent example. If the PHP MUA is busy, it can't just keep say 5 connections open to the IMAP server and have a IMAPConnectionManager object serving those out, and reusing them when user sessions are done. That simple connection pooling would probably speed up Squirrelmail and take some load of the IMAP server.

      Another thing this brings to mind is component techniques. Having object hanging around in 'Application space' encourages a lot of reuse. Eg. a single instance of ficticious IMAPConnectionManager class independent of all sessions, but available to all user session. A single instance of the 'authenticationObjectFactory' object, for instance, can be available to all user sessions, again managing that resource.

      How would you create a *single* object instance that is available to all script instances in PHP?

      Many design patterns require this. I don't think this would be missed on small scripts, but web applications that are designed to be scalable, secure benefit from those patterns greatly.

      My opinion is that PHP is a great language that's not stepping up to the plate. In the early 90's when everyone use CGI, the web script design was find. Now things are a lot more complex, I believe, and a lot more is expected from web-deployed applications. A few of those features would help PHP coders pitch PHP solutions against the growing popularity of application servers, eg. ASP.NET, JSP/J2EE, Cold Fusion, etc.

      --
      Based on upvotes, Ageism is the only "-ism" Slashdotters care about and think isn't SJW
  35. Re:The superiority of PHP over Perl by RedK · · Score: 1
    Before anyone gets their Perl backs up, let me point out why a good default install is important for web development: you don't always have control over the server, so you can't always get the Perl modules you want.

    Ok, so I guess you don't get the chance to recompile the php module either if you really need some extra fonctionnality your webhost doesn't provide on their default PHP install.

    Fun fact, if the Perl modules I need aren't available, I can always upload them to my webspace as @INC points to ./ for modules. Something I can't do for PHP if I need the extra fonctionnality.

    Nice one, trolling on top of a troll.

    --
    "Not to mention all the idiots who use words like boxen."
    Anonymous Coward on Monday August 04, @06:49PM
  36. What? No OOP fight? by Tablizer · · Score: 2, Funny

    I expected somebody to come in and say, "PHP's object support is not very good and OO and GOF patterns are the savior of code management and mega-reuse and getting dates, etc. etc." But I have not seen that. What's an OO critic to do? :-)

    1. Re:What? No OOP fight? by maelstrom · · Score: 1
      What's an OO critic to do? :-)

      Wait for PHP5. :)

      --
      The more you know, the less you understand.
  37. Don't judge PHP/XML yet, look forward to PHP5. by chregu · · Score: 2, Interesting

    PHP 5 will have much much better XML support.

    There is a lot of work on a complete new DOM extension, which should clean up the mess done in domxml as of PHP 4. It will follow the W3C DOM API as much as possible and is completely rewritten from scratch.

    Furthermore Sterling Hughes is working on SimpleXml. An extension which should make it much easier to access XML Documents with the usual PHP functions.

    The SAX Parser in PHP 5 will also be based on libxml2 and not anymore on the aging expat library.

    XML Validation, XPath and XSLT support are also currently revised and should be improved a lot in PHP5.

  38. MOD PARENT UP - Great Point. by Anonymous Coward · · Score: 0

    Seriously....from all the hype and noise, a non-php'er must think the only thing to do with php is use it w/ mySQL.... ..oh uh, don't get me wrong i love using php w/ mySQL and PostgreSQL ;-)

  39. OOP with PHP by skamp · · Score: 0, Flamebait

    The OO of PHP is excellent.
    What does OO mean to you? I could be wrong, but I really think it means Object Oriented. I think there's a P missing in your sentences, standing for Programming.

    The OOP features of PHP are excellent.
    Destructors, private namespaces, multiple heritage: these are features PHP is currently lacking (I don't know if PHP 5 will offer such features). How is it better than other languages, OOP-wise (honest question)?

    1. Re:OOP with PHP by Kaemaril · · Score: 1

      OO = Object Orientation?

    2. Re:OOP with PHP by Guido+von+Guido · · Score: 1
      I vote for kludge. This is one of the reasons I stopped using PHP and went back to perl. (Yes, Perl's OO implementation is also something of a kludge, but it's a better and more useful kludge. I've really been liking Ruby lately, but it doesn't have the libraries yet.).

      Apparently PHP 5 will have a "new object model." While this is good, I have to admit it doesn't necessarily inspire confidence. The basic design of the language seems sloppy as hell to me, too. It seems like at every minor release they've realize that, oh, $this wasn't such a good idea, let's implement $that to get around it/fix it. The namespace is so polluted with every little function, it's difficult to add components, etc., etc.

      To be fair, PHP 5 might be a big improvement there, too.

      On the other hand, it is a great language for relatively simple web scripts, and it is easy to learn.

  40. Re:The superiority of PHP over Perl by eddy+the+lip · · Score: 1

    I both agree and disagree...

    I hate having every_goddamn_function() in the global namespace. I would much rather drag in what I need when I need it, a la perl. However, what drove me from mostly perl development to mostly PHP development is that you're pretty sure you'll have most everything you need built in with the latter. The simple fact of not necessasrily having perl's DBI module installed on a server you don't control (and have no access to gcc on) forced the decision to use PHP for most things over here.

    Of course, PHP might not have everything you need built in, either. Need to generate images? If the server doesn't have PHP compiled with gd support, you're out of luck. It does happen less often, though.

    The one thing I would love to see from perl is a standard web app bundle. Something that was a no brainer for admins to install when perl's installed. DBI, AxKit or Mason or similar...etc. Something you could count on being there. Then I could get back to a language that fits my brain better.

    --

    This is the voice of World Control. I bring you Peace.

  41. Definitely Worth the Buy by GreyLurk · · Score: 2, Informative

    I've been using this book for about 3 months, and I'm no Newbie to PHP programming but it's got some invaluable stuff in there.

  42. Perl HERE docs by goombah99 · · Score: 1
    I've never understood what the attraction of php over perl is, maybe someone could explain. When I look at the two of them it looks like for simple pages they are about equal: peanut butter in chocolate verus chocolate in peanut butter.

    For example,
    php embeds code-like active statements in between static html. where as perl embeds HTML text in between perl commands. Each of them requires designated separators to keep the text and commands separated.


    to be a little more specific, since perl had HERE statements one can have an entire perl cgi script that basically looks like a an html page:



    sample perl cgi script:
    print HERE1 # slashdot wont print the less than signs
    this is a bunch of html here.....
    HERE1

    $d = 4.5 # some perl commands

    print HERE2 # slashdot wont show the less than signs
    more $d lines of perl
    HERE2

    I dont see how the separators in perl between HTML text and perl commands add any bulk or inconvnience. Yet perl can do so much more than PHP.


    hence my orignal query. What am I missing here. why is there any preference for PHP? is i somehow faster or lighter weight on APACHE? (that say fastCGI is not). I'm stumped. someone please explain!

    --
    Some drink at the fountain of knowledge. Others just gargle.
    1. Re:Perl HERE docs by bloodpet · · Score: 1

      # slashdot wont print the less than signs Have you tried < (&lt)?

      --
      Truth is like a shining mirror that's been shattered.
    2. Re:Perl HERE docs by Anonymous Coward · · Score: 0

      (&lt) No but thank you for the attempted tip- it does not seem to work (&gt)

    3. Re:Perl HERE docs by Anonymous Coward · · Score: 0

      try it with a semicolon
      &lt;
      <

  43. Wrong price! by Anonymous Coward · · Score: 0

    (or $61.95 CAD)

    It costs $43.37 CAD
    http://www.amazon.ca/exec/obidos/ASIN/1565926 811/7 02-9229668-4523225

    With Amazon.ca's FREE shipping and $18.58 in savings I was able to donate my extra $18.58 to the EFF which I think has gone further to battle crazy patents like Amazon.ca has and help support their various causes plus I still spent the same amount as I would at BN and just supported them instead with no donation to EFF. Using Amazon's low price against them. Gotta love it.

  44. One damn fine thing about PHP as opposed to C. by Anonymous Coward · · Score: 0

    Including files is done via a function instead of the preprocessor. W00t!

  45. Fortran is faster than C by Anonymous Coward · · Score: 0
    gee if speed is the only issue maybe you should re-write PHP in fortran! its even faster than C. And on the client side why not use say, active-X, that's faster than java too if you dont mind security holes.

    ("C" is a language which never dies!!)

    And fortran is still kicking too, sonny.

  46. Re:The superiority of PHP over Perl by namekuseijin · · Score: 2, Interesting

    >>Recently I've had a chance to do some web design with PHP.

    some (?) web design (??)... how much of it to begin with?

    >>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!

    Perhaps your surprise came from the fact that you were using CGI Perl and that PHP was a fast Apache module? You'd be surprised to learn, though, that today there's also a Perl Apache module as well which is as fast or faster than PHP's...

    >>I know this is a bold statement, but I have solid arguements to support it.

    You better have them as we'll see below...

    >>I'm not arguing that PHP is better than Perl in all cases. There is certainly still a use for Perl.

    Actually, it's the contrary: Perl is one of the most flexible and faster high level languages in existence. It is used for nearly any tasks imaginable dealing mostly with character string processing, that is, it's an overall great general purpose Turing machine. PHP for some misterious reason is used solely as a tool for building html pages, or perhaps PDF using some commercial library...

    Besides, you're aware that php was born from Perl, aren't you? They just dumbed it down so as not to scare ex-M$ users away and because of this the language just lost much of its strengh and flexibility. Ever heard of Perl's motto: "There's more than one way to do it"? It means you can express the same computation many different ways. It means, for instance, that you may express in purely procedural fashion or object oriented, where you see fit. In php (and Python as well) you're trapped in OO craze. There's just one way to do things.

    Also, Perl is one of the most compact (and therefore faster) languages in existence. Of course, people's unwillingness to learn the language make them look at features such as "do { print if /anypattern/; } while();" as beyond their comprehension, but it's not the language's fault if they don't wanna use some the languages builtin features for their great advantage...

    So, i say, i'm not saying Perl is better than php in all cases, there's certainly still a use for php... :)

    >>Finally, I'm not the most talented Perl programmer out there.

    That seems obvious!

    >>I generally prefer to use the vastly superior Python, but can use Perl if I have to.

    I like Python too and highly regard it to be Perl's spiritual brother. But i wouldn't say one or the other is better. Though i would take Perl's flexibility and compactness over Python's rigid OO syntax anyday. One thing is true: they both beat the crap out of php and its VB-like stand...

    >>* Ease of use. I would definitely not recommend anyone new to programming begin with Perl.

    I wouldn't say ease of use is one of Perl's deficiencies. But surely the learning curve for the language is kinda steep. Still, power comes at a price and if you are willing to use a powerful tool you'd better learn how to use it and use it well.

    I can say once you learn Perl right, most other languages just feel like lacking in flexibility, expressiveness or compactness.

    Yes, if you never used a katana, you'd better get to grips first with a bamboo stick or something.

    >> * The OO of PHP is excellent. In my experience, it rivals Smalltalk.

    Who do you think you're fooling? PHP's OO features are more like Javascript than Smalltalk, stop daydreaming. If you want high level OO stuff go with Python's multi-inheritance model.

    >>Hopefully Perl will be patched up so it supports such must-have OO features like introspection, reflection, self-replication and ontological data-points.

    When there's real need for such features, yes. Because Perl doesn't force you into OO syntax, many constructs which just make sense in a purely OO view of the world are not really need

    --
    I don't feel like it...
  47. Re:Enough MySQL by Decaff · · Score: 1

    I spend too much of my job re-writing code for projects
    that started small and then grew.

    Surely its simply good practice to design and code with
    scalability and performance built in? Postgresql is no
    harder to use that MySQL is it?

  48. I would be ecstatic... by Kickstart70 · · Score: 1

    ...if php would just include one tiny bit of perl goodness: "~="

    Instead, I've got to write ugly crap like "if (strpos($alltext, "This string") >-1)" in order to check if a variable contains a string.

    In Perl? "if ($alltext ~= "This string")". Much nicer.

    1. Re:I would be ecstatic... by Naum · · Score: 1
      ...if php would just include one tiny bit of perl goodness: "~="

      Instead, I've got to write ugly crap like "if (strpos($alltext, "This string") >-1)" in order to check if a variable contains a string.

      In Perl? "if ($alltext ~= "This string")". Much nicer.

      if (preg_match('This string', $alltext))

      --

      AZspot
    2. Re:I would be ecstatic... by Anonymous Coward · · Score: 0

      Try "$str_exists = stristr($alltext, 'This string') ? true : false"

  49. YHBT. HTH. HAND. by Anonymous Coward · · Score: 0

    This is the comment, even though I wanted to just post a subject since it was sufficient to say all that was necessary, Slashdot (pbui) didn't let me do that - hence this self-referential paragraph.

  50. php maybe not... by Anonymous Coward · · Score: 0

    1. Many fetures are not present in the distribution. For example, pdf creation. So, you have to run around and get code for pdf creation. Most of the code you will run accross will have a license fee associated with it or be sub par. Ohh, they will tell you it supports pdf creation out of the box but all the images are water marked. Yep, totally useless. Thus, you have to pay the license or find an alternative.

    2. They changed the names of the functions. I like the function naming in perl because it is similiar to c. This makes it easier for the programmer.

    3. Everytime you want a new feature you have to totally recompile their apache module. ( or apache also if your dense ) With perl just goto cpan and install the new module and pod files.

    4. Regular expressions and pattern matching are cleaner under perl. In java I have to call functions like php to do a regex.

    5. There is no debugger. With perl there is a default real world debugger. Thank god for "perl -d". No, debugging is more than farting out an error to the page displayed. A debugger is more than echoing out to a terminal.

    6. Yes, object oriented code under php is really lame. Honest.

    7. The latest version of perl has a switch statement now.

    8. php like perl is an interpreted language. Thus, it is slower. It is good for a service environment but not the vender environment. Ya, Java is interpreted also. But I can run the jgc compiler ( from the people who wrote gcc ) on it and get native code that is fast. Again, if your going to compile php then you have to pay a license again. ( see the pattern now! )

    9. If you switch to php then you have to buy all those books.

    I'd say php is good for basic web page database situations. But that is about it. But I can do the same thing in perl just as easy and have a more mature development environment.

    Real men program in c anyways...if its good enough for the kernel its good enough for me. :)

    1. Re:php maybe not... by Anonymous Coward · · Score: 0

      That is gcj not jgc. [correction]

      http://gcc.gnu.org/java/

    2. Re:php maybe not... by codewritinfool · · Score: 1

      Ok, I'll bite. I'm not a PHP expert, but I think I can respond to a few of these statements.
      3. Huh? I don't do this when I add a module. ???
      5. There is a debugger. And here.
      8. There is a free PHP Accelerator for non-Windows boxes.

      Just my two cents.

  51. MySQL is not easier than PostgreSQL by brlewis · · Score: 1

    I've used both MySQL and PostgreSQL. In my experience MySQL is not easier.

  52. Re:Things PHP is missing (cont.) by Mysticeti · · Score: 1

    5) native MySQL transaction support

  53. Re:The superiority of PHP over Perl by Anonymous Coward · · Score: 1, Informative

    1. php + Smarty looks like cgi to me
    2. who in their right mind would *want* to mix html with their code? When I was handed a vendor's solution with php + html mixed in a single file the first
    thing I did was separate the two. How the hell can you see what is going on?
    3. so much of php looks like it was lifted right from perl.
    4. the real die hards are on a crusade to re-write the whole world in php. gotta laugh.
    5. how come just about every site, every book on php is geared towards amatuers? I can never find any depth. Even the manual on php.net has big holes in it.
    6. why are there 4 versions of the split function?
    7. as for all options being compiled in, they aren't. Did you ever try to build php for the first time? You'll spend hours trying to figure out which options you should include.

  54. Obligatory Smarty plug by mlas · · Score: 2, Informative

    1 - It lets you mix html and code in. Sure, it's not the only language that lets you do it, but it's still a strength.

    I thought that PHP did a great job of mixing HTML and code until my PHP apps started reaching a certain size. Even using function calls and classes, templates started getting convoluted. Then I discovered Smarty and my whole way of working changed. Smarty is a template manager that allows for more precise separation of content and code. As a super-simple example, lines like become {$variable}. Over the course of a whole site, the savings from this syntax alone ease code readability (yes i care about such a thing). But there's a lot more to smarty than shorter variables, including shorthand for string modifiers and loops, as well as a nifty caching system that can speed up dynamically generated sites, and zillions of other really cool things for "lazy" programmers like me.

    A lot of people on this thread have mentioned AdoDB (my other favorite PHP add-on), but I haven't seen anyone give a proper shout out to Smarty. It's made my life easier.

    --
    "Luck is the residue of design" --Branch Rickey
    1. Re:Obligatory Smarty plug by Anthony+Boyd · · Score: 1
      As a super-simple example, lines like [some code was obviously intended to be here] become {$variable}.

      I don't understand this. Why is {$variable} so much easier or less confusing than <?=$variable?>

      The last time I was hiring PHP developers (thanks Slashdot!), I had a few people in who did this, and they'd walk me through the code. After looking at it, I'd simply change a few characters to make it use "native" PHP code, and ask, "what's the difference, why did changing a few characters make things so different?" The response I typically got was either, "because this is better," or "the designers said they could work with this better." The first reponse isn't really a reason, and I don't buy the second response, because the differences seemed so slight. So really I have a genuine question: what are the advantages? What am I missing?

    2. Re:Obligatory Smarty plug by mlas · · Score: 1
      I don't understand this. Why is {$variable} so much easier or less confusing than <?=$variable?>


      Well, on a trivial level, it's three less characters per instance; on a template with a few dozen variables, the difference in visual noise is welcome.

      But of course Smarty ain't worth it just to save three characters. More ease of use comes from Smarty's modifiers. Most of the most popular PHP functions for string display and manipulation have been added to the modifiers, with the pipe syntax: {$dateVariable|date_format}, for example. A little thing like the "default" modifier can turn this:

      <? if (empty($variable)) $variable = "None"; ?>
      <?= $variable; ?>


      into this:

      {$variable|default:"None"}

      There are dozens of these little shortcuts in Smarty, and they add up quick; I work in PHP and HTML for a good chunk of the day, and I work faster using it, as my code is about 60% as long as it was a few months ago.

      But the big, awesome, huge advantage of Smarty is the ease with which you can separate business logic from presentation logic. My dynamic PHP files now tend to look like: "1. Validate GET or POST input, 2. Make appropriate SQL queries, 3. Send raw output to template". If I need to shorten a variable to fit a design, or change a name to all caps, or format a date, that doesn't have to be coded in the same place as my business logic. I had been writing my own functions to maintain this separation, but Smarty was way ahead of me, so I switched.
      --
      "Luck is the residue of design" --Branch Rickey
    3. Re:Obligatory Smarty plug by Anthony+Boyd · · Score: 1

      Thanks mlas. Your info was interesting. Too bad the thread is so old that you're not getting moderated as such. Anyway, I have some more questions, which probably won't get answered in such an old thread, but I might as well try.

      First, I can see how {$variable|default:"None"} is less visual noise, but to me it appears ugly -- I partly chose PHP for syntax, and I prefer that kind of code to what I see with Smarty. Also, with PHP you can use ASP tags, <% code %> and it conveys a huge advantage -- if you do it right, Dreamweaver will ignore those chunks of code and render the surrounding HTML. This is a great feature that allows designers to actually modify a page without breaking code. Will Dreamweaver similarly ignore {} braces?

      But the big, awesome, huge advantage of Smarty is the ease with which you can separate business logic from presentation logic. My dynamic PHP files now tend to look like: "1. Validate GET or POST input, 2. Make appropriate SQL queries, 3. Send raw output to template". If I need to shorten a variable to fit a design, or change a name to all caps, or format a date, that doesn't have to be coded in the same place as my business logic.

      And this leads to my second question. It sounds like you just described a typical use for include_once(). In your included file, you put all the code, and in the page itself, you just sprinkle in the variables for the presentation layer. So I'm just stumped -- I'm hearing that only Really Stupid Peopleâ refuse to use a template system, but PHP appears to be able to do the same thing without any template system at all. Am I right? Is there something else I'm missing?

    4. Re:Obligatory Smarty plug by cyt0plas · · Score: 1

      I've tried smarty, for most things it isn't needed (although, I will it admit that the dropdown creation script is useful at times), and I won't accept the (minimal) overhead. I also work with other PHP developers, and I want my code to be readable by _any_ php developer, not just people familiar with smarty.

      --
      Contact Me (got tired of viruses emailing me).
  55. ASP is so 1990's... by Anonymous Coward · · Score: 0

    The world is using ASP.NET these days...

    Much much better than PHP.

  56. Formhandling by Anonymous Coward · · Score: 0

    works better on ASP.NET

    Take it from someone who has worked with real languages, and real application frameworks for HTTP, and is now desperately trying to get as far away from PHP as possible.

    foreach ("string" as $char) {
    echo ($char);
    }

  57. Why buy a book when you can download? by BladeMelbourne · · Score: 1

    I find the documentation from php.net and mysql.org to be first class.

    The Windows CHM manual for PHP is easy to navigate and search:
    http://weblabor.hu/php-doc-chm/
    PHP Documentation Downloads:
    http://www.php.net/download-docs.php
    MySQL Reference Manuals:
    http://www.mysql.com/documentation/index .html

    PDFs are ideal because you can search/print them easier than HTML. Plus they are free.

  58. Yeah, but.... by Anonymous Coward · · Score: 0
    PHP is a very powerful scripting language, so developers (not just web developers) can do almost anything with it.

    Well, I can do almost anything with a spork, too. The question is: Do I want to?

    PHP == Poorly Hung Perl

    *ducks and runs*

  59. free as in FUD by poptones · · Score: 1
    You know, I really meant "free" both ways. And I might accept that part about it overtaking others, except I've seen no evidence of it yet. Honestly, I remember (a simpler time) when PHP (ignoring the ugly syntax) actually WAS ahead of the MS solution, but it's long since been overtaken and most of the attempts at overcoming this seem to just make it even uglier.

    I've got a buncha linux machines here (in my home), too, but guess what I'm using to type this? I've yet to see a linux desktop environ that looks as slick and feels as cohesive as even my win2k desktop. It's been nearly ten years now - if what you say is true then it seems linux should be the most absolute kickass, user friendly desktop out there.. but it ain't, and not by a long shot. As convoluted and messy as win32 has become, the linux desktop STILL can't compete in overall "feel" with MS (much less Apple). Why is that?

  60. my god is better than your god by redJag · · Score: 1, Interesting

    it seems to me that most advocates of perl think perl is better than PHP, and vice-versa for PHP advocates.

    The stigma that is associated with perl is generally that "its harder, more lines of code, doesn't have the same functionality" because it takes a steeper learning curve. With PHP you can pretty much do anything right away: just search for the right function. I bet if most big PHP developers gave perl a chance, they'd be surprised.

    Same goes for the other side, however. Since PHP is easy to get started on, there are a lot more PHP newbs than there are perl newbs. This reflects poorly on PHP developers as a whole, which there are obviously some very talented ones that don't deserve said reflection. I think the big thing in PHP is "controlling the beast." It can easily become insecure, inefficient, etc. if you don't know what you're doing..and the abundance of newbs make it appear like this happens all the time.

    Anyway..I just ran outta pennies.. :D

  61. Can't teach a Perl dog PHP tricks by release7 · · Score: 1
    I'm in the middle of giving PHP a try after a couple of years with Perl. Frankly, I don't see what all the hype about PHP is. There is nothing superior about it compared to Perl. And I've recently cracked my monitor's screen beating my head into it as I try to figure out why the fu*#$^(*# code doesn't work. Every array has an iterator??? Arrays that can be either hashes OR arrays??? I still haven't figure out when the hell PHP interpolates variables and when it doesn't.

    Perl to Java was a snap---the languages are so different. But moving from Perl to PHP is driving me insane. I'm guessing I'm not the only one, am I?

    --

    <a href="http://www.joblessjimmy.com">Work is dumb and so is Jobless Jimmy.</a>

  62. pdflatex by brlewis · · Score: 1

    Ignore what the other poster said about converting dvi. Use pdflatex to go straight from latex source to pdf. The supertabular package matches so perfectly what you asked for in your first post, that I thought you might be trolling for a pdflatex answer.

  63. NO!!! by Vagary · · Score: 1

    Unfortunately, as much as Perl users often enjoy faking it with multi-line regular expressions, XML is not text. What the web needs know is the successor to Perl: a language with the DOM integrated as well as Perl integrates regular expressions. And with output of structured documents as easy as printf.

    I shouldn't have to be thinking about the fact that the data is marked up with tags when I'm parsing it. Instead, I should be able to concentrate on the fact that the data is a tree with subelements and attributes to each node. And I should never have to type angle-brackets when doing output.

    I don't know whether XPath will be part of this language -- I haven't done enough real-world development with it to be sure. But I damn well know that the OO-structure of W3C's DOM is not the ultimate tool for the job.

    1. Re:NO!!! by Christianfreak · · Score: 1

      XML is most certainly text. Its not binary! And I didn't say anything about parsing XML with regexes either. There are extensions to Perl that parse XML documents quite nicely.

    2. Re:NO!!! by Farley+Mullet · · Score: 1
      XML is most certainly text. Its not binary!

      Okay, I'm really drunk, and in over my head here, but that doesn't stop most /. posters, so it certainly won't stop me. To suggest that XML is "just text" is to miss the point of XML, and the opportunity that XML presents. XML might be formatted as text, and presented in a text-format, but it's a specialized subset of text, and the grandparent's right: because XML has a lot more structure than just-plain-vanilla-text, and that structure should be taken advantage of by languages that are are designed with a sympathy to the inherent structure of XML documents.

      Now excuse me while I drink some water so I'm not (too) hungover tomorrow. Also excuse me if i shot my mouth off beyond what my (feeble to begin with, but further enfeebled by the wonder that is alcohol) mind can back up.

    3. Re:NO!!! by Christianfreak · · Score: 1

      Alcohol and all you are correct, its just that whether or not XML is better or worse that a "vanilla" text file isn't the point. The point is that you can open an XML file in the text editor of your choice and see that structure, and I bet that a lot of people even if they hadn't seen the format before would understand it at least on some level and be able to edit it. Heck even the mime type for an XML document is (should be) "text/xml"

      Try opening a binary file in an editor. Its going to be mostly gibberish, sure you might be able to change some text strings but for the most part you're stuck with what you have.

      This thread has gone so far off-topic. My original post way up there somewhere was simply pointing out that Perl has better and more standarized ways to parse XML documents than PHP.

    4. Re:NO!!! by Vagary · · Score: 1

      text/xml != text/plain

      Regular expressions are not optimal for parsing most of the other forms of text. As XML eclipses plaintext as the most frequent MIME-type of online documents, Perl, with it's close integration of regular expressions, will no longer be the best of all possible duct tapes.

    5. Re:NO!!! by Christianfreak · · Score: 1
      Read my posts in this thread. I have not once said that regexes should be used to parse XML. What I said was:
      1. XML is still a form of text. You can look at it, you can read it, no its not text/plain that's why they call it text/xml! Were it binary then it would be called application/xml
      2. Perl has better interfaces for XML than PHP. I can say that because I use them both and doing anything with XML in PHP is a real pain.


      I'll even clarify and say that I personally have never used regexes to parse XML.

      Off-topic:
      I highly doubt that XML is going to become the be-all end all of everything just like Perl isn't the be-all end-all of programming languages, even if it is closer than most :)
    6. Re:NO!!! by Vagary · · Score: 1

      Yeah, but Perl's XML interfaces are far from optimal. Many languages support regular expressions, but I think even those who hate Perl would agree that Perl's support is the best.

      What I want is a language foo such that:
      foo is to XML as Perl is to regular expressions

    7. Re:NO!!! by Christianfreak · · Score: 1

      Yeah, but Perl's XML interfaces are far from optimal.

      I agree with that, I was only saying they're better than PHP.

      What I want is a language foo such that:
      foo is to XML as Perl is to regular expressions


      That would be cool

  64. ColdFusion beats PHP and Pearl by boy_afraid · · Score: 1

    I've got something WAY better than PHP, ASP, OR Pearl... ColdFusion (CF)!!! Yeah, yeah, it actually costs some $$$, but back when I was using version 1 or 1.5 is was very very cheap, around $300-$400 USD. Now it's in the 1 or 2 thousand USD range. But, the point is CF can do way more than any of the above is way less time. You can use any data type in any varaiable in any way and NOT have to cast the data type, use a integer in a string or vise-versa. Also, you don't have do declare a database connection every time, just do an entry in it's configuration using its administrative tools and you can just use the connection alias every where and even use multiple connection aliases in the same template and not worry about crossovers. CF also has open source add-ons to expand it's functionality. CF also works natively with Dreamweaver, Flash, and the new Flass connector. CF works on Solarix, Linux, & Windows. You name it, and it can be done with ColdFusion with less code in less time. No more C/C++ syntax. You can create your custome functions and even use it's cousing, CF Scripting. BTW, CF works great with Javascript. All the things you like about PHP is here, but better.

    Go to www.Macromedia.com and take a look at the HUGE documentation and books. Large website use ColdFusion, even my bank, Bank Of America. VMWare uses CF also.

    I cannot say enough good things about ColdFusion.

    Forgot also, works with XML, SOAP, Corba, redeveloped in native Java so you can also create in JSP and it will work. Ummm, add-ons to create PDFs, built-in scheduler, built-in search engine for indexing and searching for online documents, session and client management. There are just too many things for me to list off of the top of my head.

  65. PHP needs you! by Anonymous Coward · · Score: 0

    It's true that PHP is the little brother of Perl and Python and certainly it shouldn't be taken too seriously for anything other than web development.

    But PHP is perhaps the first truly accessible Open Source technology (mainly thanks to the manual and a well considered distribution). Yes you can do it all with mod_perl (or mod_python) but after restarting Apache for the nth time you realise PHP has a point.

    Most important is PHP has captured a dominant position on the web (over the MS alternatives). With PHP5 and the overload extension it should be possible to execute Perl and Python from PHP (e.g http://pear.php.net/package-info.php?pacid=132 ). There's some convergance of Parrot (http://www.edwardbear.org/blog/archives/000156.ht ml) as well.

    If PHP got the backing of more Open Source developers (ideally with C experience, writing extensions) it could provide the "leg up" to the other two P's into mainstream adoption online. For starters cleaning up Swig (http://www.swig.org/) support for PHP...

    ASP.NET with it's "control" library (or Sun's Java Server Faces) really do present the next generation of web development technology and PHP's playing catchup (hence "It needs you!").

    1. Re:PHP needs you! by Retarded_Ninja · · Score: 1

      PHP is more than just web development. I dont know anythign about Perl or Python, but from what I have seen is PHP can do anything I have evr asked of it. Perl has been around a lot longer. You can also write desktop Apps wtih PHP-GTK just like Perl-GTK so I truly believe that this is great time to get involved with PHP. Hopefully PHP will make ASP a thing of the past soon. :-)

  66. Personal preference by honestpuck · · Score: 1
    Good review (and not just 'cause I got a mention).

    Personally I prefer PHP Developer's Cookbook from SAMS, though it is in need of a third edition fairly soon (are you listening out there Mr Hughes). I thought it had a better organization and a wider selection of material. Just my personal preference.

    Tony Williams

  67. Did you even search PHP.net? by Anonymous Coward · · Score: 0
    Try developing on a MSSQL database with PHP, ASP or PERL and then using an Oracle database in the production enviroment. I have seen this one too many times in my web career. With CF I is a matter of changes 3 variables to accomplish the port. With PHP, ASP and PERL you either have to change a dozen or so functions or classes to accomplish the task.

    Have you never looked at PEAR? One class, 10 different databases supported. Just tell it which database you want to connect to, no changing of functions anywhere. I hand roll my own classes (change the included class and it's set for a different DB), probably not as elegant as PEAR's solution, though.

    Let's not forget that with one simple tag placed in the application.cfm, I can catch any error that bubbles up on my website, then have that error email me, allowing the user to only see an error page that I designed telling them that the error is being looked at. PHP, ASP and PERL throws the error to the webpage that the user sees. What great security that is!

    You didn't get too far with PHP's documentation, then. I can have PHP email me, too, with a complete vardump of every single variable within the page with set_error_handler() or log the error (or log things that technically aren't errors at all) however I want with error_log(). I can tell it exactly how to display the error, and even turn off emailing me and just printing the error out while I debug it so I don't receive 50,000 emails, and have it finish out the rest of the HTML on the page. I can use the trigger_error() to easily display an attractive "you forgot this field" type error message for the user.

    Immature? I think not.