????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.28 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/b8009/php-5.6.22/ext/standard/tests/general_functions/ |
Upload File : |
--TEST--
Test is_callable() function : usage variations - defined functions
--INI--
precision=14
error_reporting = E_ALL & ~E_NOTICE | E_STRICT
--FILE--
<?php
/* Prototype: bool is_callable ( mixed $var [, bool $syntax_only [, string &$callable_name]] );
* Description: Verify that the contents of a variable can be called as a function
* Source code: ext/imap/php_imap.c
*/
/* Prototype: void check_iscallable( $functions );
Description: use iscallable() on given string to check for valid function name
returns true if valid function name, false otherwise
*/
function check_iscallable( $functions ) {
$counter = 1;
foreach($functions as $func) {
echo "-- Iteration $counter --\n";
var_dump( is_callable($func) ); //given only $var argument
var_dump( is_callable($func, TRUE) ); //given $var and $syntax argument
var_dump( is_callable($func, TRUE, $callable_name) );
echo $callable_name, "\n";
var_dump( is_callable($func, FALSE) ); //given $var and $syntax argument
var_dump( is_callable($func, FALSE, $callable_name) );
echo $callable_name, "\n";
$counter++;
}
}
echo "\n*** Testing is_callable() on defined functions ***\n";
/* function name with simple string */
function someFunction() {
}
/* function name with mixed string and integer */
function x123() {
}
/* function name as NULL */
function NULL() {
}
/* function name with boolean name */
function false() {
}
/* function name with string and special character */
function Hello_World() {
}
$defined_functions = array (
$functionVar1 = 'someFunction',
$functionVar2 = 'x123',
$functionVar3 = 'NULL',
$functionVar4 = 'false',
$functionVar5 = "Hello_World"
);
/* use check_iscallable() to check whether given string is valid function name
* expected: true as it is valid callback
*/
check_iscallable($defined_functions);
?>
===DONE===
--EXPECT--
*** Testing is_callable() on defined functions ***
-- Iteration 1 --
bool(true)
bool(true)
bool(true)
someFunction
bool(true)
bool(true)
someFunction
-- Iteration 2 --
bool(true)
bool(true)
bool(true)
x123
bool(true)
bool(true)
x123
-- Iteration 3 --
bool(true)
bool(true)
bool(true)
NULL
bool(true)
bool(true)
NULL
-- Iteration 4 --
bool(true)
bool(true)
bool(true)
false
bool(true)
bool(true)
false
-- Iteration 5 --
bool(true)
bool(true)
bool(true)
Hello_World
bool(true)
bool(true)
Hello_World
===DONE===