TypePHP 编译器 https://swoole.com/aot/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

78 lines
1.8 KiB

--TEST--
Test arsort() function : usage variations - sort reference variables
--SKIPIF--
<?php
if (true) die("skip AOT does not support reference assignment in this context");
?>
--FILE--
<?php
/*
* Testing arsort() by providing reference variable array with following flag values
* flag value as default
* SORT_REGULAR - compare items normally
* SORT_NUMERIC - compare items numerically
*/
echo "*** Testing arsort() :usage variations ***\n";
$value1 = 100;
$value2 = 33;
$value3 = 555;
// an array containing integer references
$unsorted_numerics = array( 1 => &$value1 , 2 => &$value2, 3 => &$value3);
echo "\n-- Testing arsort() by supplying reference variable array, 'flag' value is default --\n";
$temp_array = $unsorted_numerics;
var_dump( arsort($temp_array) ); // expecting : bool(true)
var_dump( $temp_array);
echo "\n-- Testing arsort() by supplying reference variable array, 'flag' = SORT_REGULAR --\n";
$temp_array = &$unsorted_numerics;
var_dump( arsort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
var_dump( $temp_array);
echo "\n-- Testing arsort() by supplying reference variable array, 'flag' = SORT_NUMERIC --\n";
$temp_array = &$unsorted_numerics;
var_dump( arsort($temp_array, SORT_NUMERIC) ); // expecting : bool(true)
var_dump( $temp_array);
echo "Done\n";
?>
--EXPECT--
*** Testing arsort() :usage variations ***
-- Testing arsort() by supplying reference variable array, 'flag' value is default --
bool(true)
array(3) {
[3]=>
&int(555)
[1]=>
&int(100)
[2]=>
&int(33)
}
-- Testing arsort() by supplying reference variable array, 'flag' = SORT_REGULAR --
bool(true)
array(3) {
[3]=>
&int(555)
[1]=>
&int(100)
[2]=>
&int(33)
}
-- Testing arsort() by supplying reference variable array, 'flag' = SORT_NUMERIC --
bool(true)
array(3) {
[3]=>
&int(555)
[1]=>
&int(100)
[2]=>
&int(33)
}
Done