Monday, 2 April 2007
Determining If a Function is Available in PHP? |
| |
|
| |
Ed Winkler over a post in his blog tells you how to determine whether a function is available in PHP or not. He says that he finally got the UID and GID tests for PHPSecInfo in an acceptable state. He points out the following, which had made it difficult to determine the tests:
- You can really only do this with an
exec() call to the ‘id’ UNIX command, or the posix_* functions, either of which are frequently disabled - There basically is not a foolproof way to programmatically tell if a function is available or not in PHP
Coming back, to the main crux of the post, he says the second point of determining whether a function is available or not was quite annoying. He says, is_callable() will return TRUE even if a function has been disabled in php.ini with disabled_functions .function_exists() will return FALSE if the function is disabled in php.ini, but will return TRUE if the function is being blocked by safe_mode.
He says, for now, the tests try exec('id') first, seeing if it passes function_exists() and safe_mode is disabled. If it fails those, the posix_* functions are checked against function_exists.
|
| |
|
Read the Post
|
| |
|
|
| |
|
|
| |
|