Last night I stopped at the Whole Foods by my office to pick up some bread and cheese. The gentleman behind me in line was wearing a black Zend tshirt, and since Zend’s just down the street from us I asked him if he worked for them, and what he thought of Tim Bray’s recent post on PHP.
It turned out that this was Mark de Visser, Zend’s chief of marketing. He said he hadn’t read the post because he had spent the last two days at MashupCamp.
My take on PHP:
-
Gawd, it’s easy to jump in, and get running code.
-
Ugh, need native Unicode, badly.
Don’t feel bad, Ruby has the same problem.
PHP 6 is supposed to support UTF-8, and comes out later this year (says de Visser.)
-
PHP 5 has libxml2 and libxslt.
-
It’s still easy to do dumb things.
Own up people, how many of you have written:
$string = file_get_contents('http://example.com/restfulweb/thing?id=0001'); if ($string != '') { // do stuff }when you were in a hurry? Then didn’t replace it with cURL or PEAR HTTP::Request?*
[*] Now, it turns out that you can check HTTP return codes when you open a URL using wrappers: $http_response_header is set after you call file, and you can look in the first element to get the HTTP response code.
I didn’t know that until I read a Yahoo! Developer Network article and looked at the example code.
So if you’re making unauthenticated GETs, that’s most of what you need.
So why doesn’t http://www.php.net/file_get_contents mention this? This useful nugget of info is buried in http://www.php.net/manual/wrappers.http.php.
