Bug #60697 [Com]: gettype() cann't distinguish object and function?
| From: | a at b dot c dot de | Date: | Wed, 15 Aug 2012 03:30:05 +0000 |
| Subject: | Bug #60697 [Com]: gettype() cann't distinguish object and function? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-172615@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60697&edit=1
ID: 60697
Comment by: a at b dot c dot de
Reported by: hfcorriez at gmail dot com
Summary: gettype() cann't distinguish object and function?
Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: all
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
If you want to tell if something is a function (i.e. callable), use is_callable(). If you want to
tell if something is an object and callable, use is_object and is_callable().
Previous Comments:
------------------------------------------------------------------------
[2012-01-10 08:44:19] hfcorriez at gmail dot com
I think it's not good for use
When I want to check function and call witch $a(), I must check it's a object and
the class name is "Closure"
------------------------------------------------------------------------
[2012-01-10 08:20:50] cataphract@php.net
"function" is not a type. See http://php.net/manual/en/language.types.php
------------------------------------------------------------------------
[2012-01-10 05:25:13] hfcorriez at gmail dot com
Description:
------------
I create a lambda function with a variable, then check it type with gettype , it's
return "object", It think it's not good in here.
Test script:
---------------
$a = function(){};
$b = new stdClass();
echo gettype($a) . '|' . gettype($b); // echo 'object|object'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60697&edit=1