PHP 8.5.0 Alpha 1 available for testing

Voting

: four minus one?
(Example: nine)

The Note You're Voting On

Peter Barney
7 years ago
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' ));
}

<< Back to user notes page

To Top