On Mon, 18 Nov 2002, Leon Atkinson wrote:
> Hmm...OK. Yes, that does make is_callable return false. Can you explain
> the logic behind this? I tried lots of other values and got TRUE. For
> example:
>
> var_dump(is_callable(array('$$$','%^&'), true));
> var_dump(is_callable('%^&', true));
>
> These aren't valid identifiers, but the function is (apparently) reporting
> that syntax is OK.
The syntax check is only intended to reject arrays that don't have a
valid structure to be used as callbacks. The valid ones are supposed to
have only 2 entries, the first of which is an object or a string, and
the second one is a string. The function doesn't do any checking of the
contents of the array.
> Ah, yeah, I guess there isn't a way to tell if a method is callable
> statically or not unless you check that it contains no references to
> instance properties.
>
> So, would it be fair to say this function is intended for debugging the
> core? And, if you have the time, could you describe the situation where
> this function is useful?
It is useful when you have a function that takes a callback as a
parameter and it needs to check whether that callback is, in fact,
callable.
-Andrei http://www.gravitonic.com/
* We are not a clone. *
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php