note 107105 added to function.is-callable
| From: | passivesmokingATyahooDOTcom at osu1 dot php dot net | Date: | Sat, 07 Jan 2012 14:06:59 +0000 |
| Subject: | note 107105 added to function.is-callable | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185450@lists.php.net to get a copy of this message | ||
is_callable doesn't seem able to resolve namespaces. If you're passing a string, then the
string has to include the function's full namespace.
<?php
namespace foo\bar\baz;
function something ()
{
return (42);
}
var_dump (is_callable ('something')); // false
var_dump (is_callable ('foo\bar\baz\something')); // true
?>
It's easy to forget, but if you just prepend __NAMESPACE__ to your function name strings you
should be fine in most cases.
----
Server IP: 87.124.126.127
Probable Submitter: 82.31.125.253 (proxied: 82.31.125.253)
----
Manual Page -- http://www.php.net/manual/en/function.is-callable.php
Edit -- https://master.php.net/note/edit/107105
Del: integrated -- https://master.php.net/note/delete/107105/integrated
Del: useless -- https://master.php.net/note/delete/107105/useless
Del: bad code -- https://master.php.net/note/delete/107105/bad+code
Del: spam -- https://master.php.net/note/delete/107105/spam
Del: non-english -- https://master.php.net/note/delete/107105/non-english
Del: in docs -- https://master.php.net/note/delete/107105/in+docs
Del: other reasons-- https://master.php.net/note/delete/107105
Reject -- https://master.php.net/note/reject/107105
Search -- https://master.php.net/manage/user-notes.php