Typecasting with double-not (!!) vs. (bool)

I was asked a strange question today.  “What’s return !! $row; do?” And I had never really been witness to the syntax of the double-not ‘!!’ because really, to me, it’s a bit strange and contradictory for the coding styles I’m used to.  So I looked it up a bit more to see if it was actually faster than proper type casting with (bool)$row in php.  Nobody had any real results. I ran a quick test and sure enough using !! is faster… for arrays.  Other than that, the time is so close it’s insignificant.

Here’s the quick ‘n dirty results:

Time testing (bool) vs. !! conversions – 1,000,000 interations

converted array with (bool) done in 1.06559991837 seconds.
converted array with !! done in 0.534655094147 seconds.

converted ” with (bool) done in 0.572640895844 seconds.
converted ” with !! done in 0.523654937744 seconds.

converted (int) with (bool) done in 0.49324798584 seconds.
converted (int) with !! done in 0.5086581707 seconds.

converted object with (bool) done in 0.564023017883 seconds.
converted object with !! done in 0.556074857712 seconds.

I had to do one million iterations just so the times would add up to something substantial.  Really, the difference is only faster if you happen to want to get a quick ‘true or false’ from an array.  The rest are so insignificant it’s not worth the confusion of a double-not.  Personally, I’d rather see an actual check of $row to see if it contains something useful before returning true or false just based on it being set.  But that’s just me.


Building An API…

I’ve decided it’s important for me to be able to expand my trivia to many different platforms.  Although it’s simple to just make it for facebook and call it a day, I think it’s something that should be more than that.

So, I’m building an api for it.  The game play api (as I’ll call it) will allow me to build other front end applications, which will all effectively operate the same way… It’ll delay the release by a little bit, but it’s something I have to do.


Coming Soon: Triviosity?

A fun, quick, simple daily trivia game.  Hopefully testing next week. One of my ever growing number of facebook apps 🙂


Now Testing: Let’s Go!

I pulled my little app, “Let’s Go” out of the sandbox and it’s workin’.. or so it appears.  If you feel like playing around with a little Facebook App, then go for it.  Let me know of issues here or on the application page.


Coming Soon: Let’s Go!

Zend Framework

Multiple Paths for Zend_Layout (Modules Based Layouts)

There was some chatter about using module based layouts with Zend_Layout on freenode, so I thought I’d explore the idea a bit more.  There was this particular idea to use a plugin and a bit of application.ini/xml settings to configure it all.  But I’m a bit old school with my Zend Framework apps.