php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60697 gettype() cann't distinguish object and function?
Submitted: 2012-01-10 05:25 UTC Modified: 2012-01-10 08:44 UTC
Votes:3
Avg. Score:3.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: hfcorriez at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.8 OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hfcorriez at gmail dot com
New email:
PHP Version: OS:

 

 [2012-01-10 05:25 UTC] 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'


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-10 08:20 UTC] cataphract@php.net
"function" is not a type. See http://php.net/manual/en/language.types.php
 [2012-01-10 08:20 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2012-01-10 08:44 UTC] 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-08-15 03:30 UTC] a at b dot c dot de
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().
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 05:01:34 2025 UTC