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_slice() function : usage variations - referenced variables --FILE-- <?..
Decoded Output download
*** Testing array_slice() : usage variations ***
-- Array of referenced variables (\$preserve_keys = default) --
Did this file decode correctly?
Original Code
--TEST--
Test array_slice() function : usage variations - referenced variables
--FILE--
<?php
/*
* Test array_slice() when:
* 1. Passed an array of referenced variables
* 2. $input argument is passed by reference
*/
echo "*** Testing array_slice() : usage variations ***\n";
$val1 = 'one';
$val2 = 'two';
$val3 = 'three';
echo "\n-- Array of referenced variables (\$preserve_keys = default) --\n";
$input = array(3 => &$val1, 2 => &$val2, 1 => &$val3);
var_dump(array_slice($input, 1, 2));
echo "-- Change \$val2 (\$preserve_keys = TRUE) --\n";
$val2 = 'hello, world';
var_dump(array_slice($input, 1, 2, true));
echo "Done";
?>
--EXPECT--
*** Testing array_slice() : usage variations ***
-- Array of referenced variables ($preserve_keys = default) --
array(2) {
[0]=>
&string(3) "two"
[1]=>
&string(5) "three"
}
-- Change $val2 ($preserve_keys = TRUE) --
array(2) {
[2]=>
&string(12) "hello, world"
[1]=>
&string(5) "three"
}
Done
Function Calls
array_slice | 1 |
Stats
MD5 | 3137a8df4e1ab14bb51032c1a609d9df |
Eval Count | 0 |
Decode Time | 177 ms |