Date: 01/11/00
- Next message: markj <email protected>: "[PHP-DEV] Bug #3176: Using Bit manupulation ( Bitwise AND, OR, XOR, NOT) do not work as expected"
- Previous message: DBadmin: "[PHP-DEV] ATTACHEMENT file with mail in PHP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: apresence <email protected>
Operating system: Debian Linux 2.0.36
PHP version: 4.0 Beta 2
PHP Bug Type: Misbehaving function
Bug description: function_exists() only works for non-class member functions
Replace spam in my e-mail addy with .com (spam guard).
I heard a nasty rumor that function_exists() should return true for class names, but it doesn't do that either.
Suggestion: Provide a new function called class_function_exists() which when passed a class name (or maybe an instance of a class, but a class name seems to make more sense), and a function name defined only in that class, returns TRUE, otherwise FALSE. This would behave differently than function_exists(), even if it did work for class function names, in that it would return FALSE for functions not declared in global scope (See *A* below).
Example code:
<?php
class Foo {
function test() {
return;
}
function function_exists($name) {
return function_exists($name);
}
}
function bar() {
return;
}
function Baz() {
return;
}
function showbool($bool) {
echo ($bool ? "TRUE" : "FALSE") . "<BR>\n";
}
echo "<HTML><BODY>\n";
// First, test functionality outside of a class
showbool(function_exists('bar')); // TRUE (works)
showbool(function_exists('Baz')); // TRUE (works, a comment on the documentation page said it didn't)
showbool(function_exists('baz')); // TRUE (works, makes sense because function names are insensitive in PHP)
showbool(function_exists('Foo')); // FALSE (doesn't work)
showbool(function_exists('Foo->test')); // FALSE (doesn't work)
// Now, test functionality inside of a class
$foo = new Foo();
showbool($foo->function_exists('bar')); // TRUE (This makes sense because bar is a function declared in global scope, even though it is outside of the class)
showbool($foo->function_exists('Foo')); // FALSE (didn't work, didn't expect it to, but tried it anyway)
showbool($foo->function_exists('Foo->test')); // FALSE (didn't work, didn't expect it to, but tried it anyway)
showbool($foo->function_exists('test')); // FALSE (seems like this should return TRUE)
echo "</BODY></HTML>\n";
?>
-- 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>
- Next message: markj <email protected>: "[PHP-DEV] Bug #3176: Using Bit manupulation ( Bitwise AND, OR, XOR, NOT) do not work as expected"
- Previous message: DBadmin: "[PHP-DEV] ATTACHEMENT file with mail in PHP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

