1--TEST--
2Test array_multisort() function : usage variation - test sort order of all types
3--FILE--
4<?php
5/* Prototype  : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING|SORT_NATURAL|SORT_FLAG_CASE]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING|SORT_NATURAL|SORT_FLAG_CASE]], ...])
6 * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
7 * Source code: ext/standard/array.c
8 * Alias to functions:
9 */
10
11echo "*** Testing array_multisort() : usage variation  - test sort order of all types***\n";
12
13// Define error handler
14function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
15	// We're testing sort order not errors so ignore.
16}
17set_error_handler('test_error_handler');
18
19// define some classes
20class classWithToString {
21	public function __toString() {
22		return "Class A object";
23	}
24}
25
26class classWithoutToString { }
27
28$inputs = array(
29      'int 0' => 0,
30      'float -10.5' => -10.5,
31      array(),
32      'uppercase NULL' => NULL,
33      'lowercase true' => true,
34      'empty string DQ' => "",
35      'string DQ' => "string",
36      'instance of classWithToString' => new classWithToString(),
37      'instance of classWithoutToString' => new classWithoutToString(),
38      'undefined var' => @$undefined_var,
39);
40
41var_dump(array_multisort($inputs, SORT_STRING));
42var_dump($inputs);
43
44?>
45===DONE===
46--EXPECTF--
47*** Testing array_multisort() : usage variation  - test sort order of all types***
48bool(true)
49array(10) {
50  ["empty string DQ"]=>
51  string(0) ""
52  ["uppercase NULL"]=>
53  NULL
54  ["undefined var"]=>
55  NULL
56  ["instance of classWithoutToString"]=>
57  object(classWithoutToString)#2 (0) {
58  }
59  ["float -10.5"]=>
60  float(-10.5)
61  ["int 0"]=>
62  int(0)
63  ["lowercase true"]=>
64  bool(true)
65  [0]=>
66  array(0) {
67  }
68  ["instance of classWithToString"]=>
69  object(classWithToString)#1 (0) {
70  }
71  ["string DQ"]=>
72  string(6) "string"
73}
74===DONE===
75