|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-10-30 16:02 UTC] johannes@php.net
[2010-11-08 23:49 UTC] hn dot campbell at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 13:00:01 2025 UTC |
Description: ------------ There doesn't seem to be any good way to check whether a variable is a closure/anonymous function. If $fn = function() { }; gettype($fn) is "object", and there is no is_function() or equivalent. The only way seems to be gettype($fn) == "object" && get_class($fn) == "Closure" but the anonymous function documentation says that the fact that anonymous functions have class Closure "is an implementation detail and should not be relied upon." I suggest: 1. gettype() returns "function" or "closure" when passed a closure. 2. is_function() is created that returns true when passed a closure, otherwise false.