[PHP-DEV] PHP 4.0 Bug #6741 Updated: gettype of 'user function' returns null From: Bug Database (php-dev <email protected>)
Date: 09/25/00

ID: 6741
User Update by: ping <email protected>
Status: Analyzed
Bug Type: Documentation problem
Description: gettype of 'user function' returns null

more examples:

<?
$z=33;
function normal()
        {
        $a=1;
        }

class class1
{
function classfunction1()
        {
        $b=2;
        }
}
$myclass=new class1;
echo "myfunction is of type ", gettype($myclass->classfunction1),"<br>\n";
echo "b is of type ", gettype($myclass->b),"<br>\n";
echo "z is of type ", gettype($z),"<br>\n";
echo "normal is of type ", gettype($normal),"<br>\n";
echo "class1 is of type ", gettype($class1),"<br>\n";
echo "myclass is of type ", gettype($myclass),"<br>\n";
echo "classfunction1 is of type ", gettype($classfunction1),"<br>\n";
?>

this piece of code, run both on PHP 3.0.12 and PHP 4.0.2 gives these different results:

ouput by PHP 3 .0.12:

myfunction is of type user function
b is of type string
z is of type integer
normal is of type string
class1 is of type string
myclass is of type object
classfunction1 is of type string

output by PHP 4.02:

myfunction is of type NULL
b is of type NULL
z is of type integer
normal is of type NULL
class1 is of type NULL
myclass is of type object
classfunction1 is of type NULL

Previous Comments:
---------------------------------------------------------------------------

[2000-09-25 16:41:48] ping <email protected>
The doc at http://www.php.net/manual/function.gettype.php
says:
> gettype -- Get the type of a variable
> Description
> string gettype (mixed var)
> Returns the type of the PHP variable var.
> Possibles values for the returned string are:
> "boolean"
> "integer"
> "double"
> "string"
> "array"
> "object"
> "resource"
> "user function"
> "unknown type"

I wonder what happens with other types as 'object' or 'resource'
Anyway the string 'NULL' doesn't seem to be among the possible returned values.

---------------------------------------------------------------------------

[2000-09-23 22:26:27] stas <email protected>
I don't see any mention in the manual that gettype should work on functions - only on variables. In fact, it cannot veen return "user function" now, so I put it in doc's problem.

---------------------------------------------------------------------------

[2000-09-20 05:23:16] ping <email protected>
It WAS undocumented but working on php3.
It IS documented and doesn't work on php4

<?
class class1
{
function classfunction1()
  {
  $b=2;
  }
}
$myclass=new class1;
echo "classfunction1 is of type ", gettype($myclass->classfunction1),"<br>n";
?>

---------------------------------------------------------------------------

[2000-09-16 18:21:49] stas <email protected>
Please provide a code example.
Also, I guess you should never rely on undocumented behaviour to preserve, anyway.

---------------------------------------------------------------------------

[2000-09-13 19:16:44] ping <email protected>
gettype() on function names returns null

Although undocumented, in version 3 it properly returned 'user function'.

---------------------------------------------------------------------------

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

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>