????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 216.73.216.238 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 : /proc/self/root/home/b8009/php-5.6.22/ext/standard/tests/array/ |
Upload File : |
--TEST-- Bug #24980 (array_reduce() uses first element as default running total) --FILE-- <?php /* test #1: numeric data */ function add_up($running_total, $current_value) { echo "running_total is ".(int)$running_total.", current_value is {$current_value}\n"; $running_total += $current_value * $current_value; return $running_total; } $numbers = array (2,3,5,7); $total = array_reduce($numbers, 'add_up'); print "Total is $total\n"; /* test #2: string data */ $a = array("a", "b", "c"); function foo ($a, $b) { return $a . $b; } var_dump(array_reduce($a, "foo")); /* test #3: basic test (used to leak memory) */ function rsum($v, $w) { $v += $w; return $v; } function rmul($v, $w) { $v *= $w; return $v; } $a = array(1, 2, 3, 4, 5); $x = array(); $b = array_reduce($a, "rsum"); $c = array_reduce($a, "rmul", 10); $d = array_reduce($x, "rsum", 1); var_dump($b, $c, $d); ?> --EXPECT-- running_total is 0, current_value is 2 running_total is 4, current_value is 3 running_total is 13, current_value is 5 running_total is 38, current_value is 7 Total is 87 string(3) "abc" int(15) int(1200) int(1)