|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-07-08 11:29 UTC] sniper@php.net
[2004-07-08 19:07 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 10:00:01 2025 UTC |
Description: ------------ When the second argument to usort() is not a valid callback, no error is triggered, and the return value is true. This makes debugging tricky. When invoked with an invalid callback, usort() for some reason rearranges the values in the array anyway. Reproduce code: --------------- <?php error_reporting(E_ALL); $array = array(1, 7, 3, 2); var_dump(usort($array, 'not a function name')); var_dump($array); var_dump(usort($array, 9999)); var_dump($array); var_dump(usort($array, array('foo', 'bar'))); var_dump($array); ?> Expected result: ---------------- The output should be three error messages, three times "bool(false)" and three times the original array. Actual result: -------------- bool(true) array(4) { [0]=> int(2) [1]=> int(3) [2]=> int(7) [3]=> int(1) } bool(true) array(4) { [0]=> int(1) [1]=> int(7) [2]=> int(3) [3]=> int(2) } bool(true) array(4) { [0]=> int(2) [1]=> int(3) [2]=> int(7) [3]=> int(1) }