ID: 20216
User updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Feedback
+Status: Open
Bug Type: Documentation problem
Operating System: RH 7.3
PHP Version: 4CVS-2002-11-01
New Comment:
OK, here's some additional information about the function that should
be enough for writing documentation.
When the second argument is true, the function only checks that the
value passed for the first argument follows the correct format. That
is, it's either a string or an array with two elements. If an array, a
check is made that the first element is a string or an object and the
second element is a string. In this mode, no check is made for the
existence of the function.
The third argument receives a description of the function meant for the
user to read. The description isn't implying anything about a method
being callable statically. (In fact, on this point, this might be my
own imagination and not something anyone else would guess.)
Here's a reasonable example of use.
<?
function callIfPossible($f)
{
if(is_callable($f, FALSE, $callName))
{
call_user_func($f);
}
else
{
print("Unable to call $callName<br>");
}
}
function a()
{
print('function a<br>');
}
class c
{
function m()
{
print('method m<br>');
}
}
callIfPossible('a');
callIfPossible('b');
callIfPossible(array('c', 'm'));
callIfPossible(array('d', 'm'));
?>
Previous Comments:
------------------------------------------------------------------------
[2002-11-18 02:01:01] [EMAIL PROTECTED]
This is now (almost) documented and can be seen here:
http://cvs.php.net/co.php/phpdoc/en/reference/var/functions/is-callable.xml
It's currently commented out as I'm not comfortable with these docs or
this topic. Please provide some more feedback :)
------------------------------------------------------------------------
[2002-11-01 16:53:24] [EMAIL PROTECTED]
Please add a description of is_callable to the documentation. Here are
some rough notes about how what this function does.
This function wraps zend_is_callable. The first argument is the name
of a function or method. Class an object methods are specified by
passing an array with two elements: class or object and method name.
The second argument seems to be for checking syntax only, but I can't
figure out how to make is_callable return FALSE when the second
argument is TRUE.
The third argument receives the "callable name". In the example below
it's "a::b". Note, however, that despite the implication that a::b()
is a callable static method, this is not the case.
<?
class a
{
var $c;
function b()
{
return($this->c);
}
}
$d = new a;
if(is_callable(array($d, 'b'), FALSE, $name))
{
print($name);
}
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20216&edit=1
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php