PHP 4.0 Bug #6741 Updated: gettype of 'user function' returns null
| From: | Bug Database | Date: | Sun, 15 Oct 2000 15:28: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-35050@lists.php.net to get a copy of this message | ||
ID: 6741
Updated by: jmoore
Reported By: ping@alt.it
Status: Analyzed
Bug Type: Scripting Engine problem
Assigned To:
Comments:
I would not say this is a docu problem but a scripting engine problem, This behaviour should really
be working, I dont think the docu's should be changed just because it doesnt, instead it should
be fixed.
James
Previous Comments:
---------------------------------------------------------------------------
[2000-09-25 20:34:08] ping@alt.it
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
---------------------------------------------------------------------------
[2000-09-25 16:41:48] ping@alt.it
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@php.net
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@alt.it
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@php.net
Please provide a code example.
Also, I guess you should never rely on undocumented behaviour to preserve, anyway.
---------------------------------------------------------------------------
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