Created
March 11, 2015 15:03
-
-
Save itthinx/da9eb5128236121d31bf to your computer and use it in GitHub Desktop.
PHP Bug Warning: uksort(): Array was modified by the user comparison function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The following will produce this result: | |
* | |
* Warning: uksort(): Array was modified by the user comparison function in /Users/kento/Sites/uksort.php on line 12 | |
* set = array ( 'apple' => 'green', 'color' => 'yellow', 'wine' => 'white', 'yoghurt' => 'frozen', ) | |
* | |
* See also https://bugs.php.net/bug.php?id=50688 | |
**/ | |
ini_set( 'display_errors', 1 ); | |
$set = array( 'color' => 'yellow', 'apple' => 'green', 'yoghurt' => 'frozen', 'wine' => 'white' ); | |
function foo( $a, $b ) { | |
new Exception(); | |
return strcmp( $a, $b ); | |
} | |
uksort( $set, 'foo' ); | |
echo ' set = ' . var_export( $set,true ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment