By Matt Butcher
php 5.3
PHP Phar command line errors on OS X: Running 'php some.phar' generates '?????'
Submitted by matt on Wed, 2010-09-15 16:36When I tried to run pyrus.phar on Mac OSX recently, I had a strange experience. Executing php pyrus.phar generated the output ??? and then exited. With a little more testing, I discovered that all of my Phar packages, when from from the command line, generate "garbage" output (a series of question marks, usually) and then exit.
Quite a bit of digging later, I discovered an old bug report (recently re-opened) that documents the problem and suggests a solution. In a nutshell, the problem is that the Zend engine Unicode checker is enabled by default in at least some versions of PHP 5.3. My Apple-built PHP package (included in the Snow Leopard releases) has this problem, and I suspect that other builds do too.
While there is no solution yet, the workaround is as simple as setting the following ini directive:
detect_unicode = Off
While I'm not a huge fan of this workaround, it definitely works. I simply added it to my /etc/php.ini file, and now I can run pyrus and other Phar files.
Streamlining Iterators in QueryPath 3.x
Submitted by matt on Tue, 2009-12-01 21:21Work has officially begun on QueryPath 3.x. The upcoming release is focused on implementing and supporting many of the new features introduced in PHP 5.3, including enhanced SPL support, namespaces, closures, and phar archives.
In an earlier article, I examined the performance of various iteration strategies in QueryPath. After taking a hard look at the patterns I observed there, I revisited QueryPath's QueryPathIterator class to see if I could make a sizable performance improvement.
Iteration Techniques and Performance in QueryPath
Submitted by matt on Thu, 2009-11-26 11:41QueryPath provides multiple methods of iterating. This article demonstrates the performance impact of various looping types. In this article, we are going to look at four different ways of iterating through the items wrapped by a QueryPath object:
- Using QueryPath's iterator
- Looping through
DOMNodeobjects - Using
each()and a callback - Using
each()and an anonymous function
This last item is specific to PHP 5.3 and later, and offers intriguing possibilities when paired with closures.
Finally, at the end of the article, I will show some representative performance numbers.








