PHP 4.0 Bug #6741 Updated: gettype of 'user function' returns null

From: Date: Fri, 03 Nov 2000 05:01:15 +0000
Subject: PHP 4.0 Bug #6741 Updated: gettype of 'user function' returns null
Groups: php.dev 
Request: Send a blank email to php-dev+get-36907@lists.php.net to get a copy of this message
ID: 6741 Updated by: ronabop Reported By: ping@alt.it Status: Closed Bug Type: Documentation problem Assigned To: Comments: Documented. Previous Comments: --------------------------------------------------------------------------- [2000-10-23 04:58:19] stas@php.net This is not a bug. I repeat: This. Is. Not. A. Bug. gettype is meant to get type of a variable. Function is not a variable. Thus, you can not use gettype on a function. If you need to check existance of a function with given name, use function_exists. --------------------------------------------------------------------------- [2000-10-23 04:53:34] ping@alt.it This bug now can be circumvented by using the new method_exixts() functionof PHP4. It is only viable for class methods though. I think that for backward compatibility, and to keep in line with the old and new documentation, it shouldn't be too hard to have gettype() return 'user function' too. Otherwise relegate it as a docu error and thanks for the help Meanwile I posted a new version of the php4 implementation of 'remote scripting' that uses 'method_exixts()? instead on php-general list and am awaitimg a feedback from the original author. --------------------------------------------------------------------------- [2000-10-22 12:27:57] ping@alt.it This missing functionality actually breaks the PHP 'remote scripting' interface, as discussed some time ago in the php mailing list See messages about 'remote scripting' starting at http://marc.theaimsgroup.com/?l=php-general&m=92113045423518&w=2 --------------------------------------------------------------------------- [2000-10-19 12:05:02] ping@alt.it It was not me who invented this function, although I've been using it since 3.12. It is quite useful for marshallizing and serializing things, and it gives a bit of introspection to PHP. And as in PHP4 the developers have thought to increase the scope of gettype() to new types as 'properties', which are still a bit of a mystery, I thought the old ones would still work. Nevertheless $myclass->b in the esample above is an integer variable, better said an 'object property', and not a string (PHP3) nor NULL (PHP4). --------------------------------------------------------------------------- [2000-10-18 06:07:59] stas@php.net What should be working? Function is not a variable, what type do you expect to get from there? Do you want PHP also to return gettype($if) as "PHP language construct" and gettype($Bill_Clinton) as "US president"? gettype returns types of variables, that's it - it can not return type of whatever object that is not a variable. --------------------------------------------------------------------------- The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online. Full Bug description available at: http://bugs.php.net/?id=6741

« previous php.dev (#36907) next »