Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
--TEST-- Test array_filter() function : usage variations - Different types of 'callback' f..
Decoded Output download
*** Testing array_filter() : usage variation - different 'callback' functions***
-- Callback function without parameter and with return --
Did this file decode correctly?
Original Code
--TEST--
Test array_filter() function : usage variations - Different types of 'callback' function
--FILE--
<?php
/*
* Passing different types of callback functions to array_filter()
* with parameters and return
* without parameter and with return
* with parameter and without return
* without parameter and without return
*/
echo "*** Testing array_filter() : usage variation - different 'callback' functions***\n";
// Initialize variables
$input = array(0, -1, 2, 3.4E-3, 'hello', "value", "key" => 4, 'null' => NULL);
function callback1()
{
return 1;
}
echo "-- Callback function without parameter and with return --\n";
var_dump( array_filter($input, "callback1") );
// callback function with parameter and without return value
function callback2($input)
{
}
echo "-- Callback function with parameter and without return --\n";
var_dump( array_filter($input, "callback2") );
function callback3()
{
}
echo "-- Callback function without parameter and return --\n";
var_dump( array_filter($input, "callback3") );
// callback function with parameter and with return value
function callback4($input)
{
if($input > 0 ) {
return true;
}
else {
return false;
}
}
echo "-- Callback function with parameter and return --\n";
var_dump( array_filter($input, "callback4") );
echo "Done"
?>
--EXPECT--
*** Testing array_filter() : usage variation - different 'callback' functions***
-- Callback function without parameter and with return --
array(8) {
[0]=>
int(0)
[1]=>
int(-1)
[2]=>
int(2)
[3]=>
float(0.0034)
[4]=>
string(5) "hello"
[5]=>
string(5) "value"
["key"]=>
int(4)
["null"]=>
NULL
}
-- Callback function with parameter and without return --
array(0) {
}
-- Callback function without parameter and return --
array(0) {
}
-- Callback function with parameter and return --
array(5) {
[2]=>
int(2)
[3]=>
float(0.0034)
[4]=>
string(5) "hello"
[5]=>
string(5) "value"
["key"]=>
int(4)
}
Done
Function Calls
array_filter | 1 |
Stats
MD5 | 44e8cabf1837a991d380e8d37aa1ea19 |
Eval Count | 0 |
Decode Time | 106 ms |