As noted earlier, is_string() returns false on an object that has a __toString() method. Here is a simple way to do a check that will work:
<?php // determine if the passed argument can be treated like a string. function is_stringy($text) { return (is_string($text) || (is_object($text) && method_exists($text, '__toString' )); }