1--TEST--
2Test strtr() function : usage variations - empty string & null for 'str' argument
3--FILE--
4<?php
5/* Testing strtr() function by passing the
6 *   empty string & null for 'str' argument and
7 *   corresponding translation pair of chars for 'from', 'to' & 'replace_pairs' arguments
8*/
9
10echo "*** Testing strtr() : empty string & null for 'str' arg ***\n";
11/* definitions of required input variables */
12$count = 1;
13
14$heredoc_str = <<<EOD
15
16EOD;
17
18//array of string inputs for $str
19$str_arr = array(
20  "",
21  '',
22  FALSE,
23  false,
24  $heredoc_str
25);
26
27$from = "";
28$to = "TEST";
29$replace_pairs = array("" => "t", '' => "TEST");
30
31
32/* loop through to test strtr() with each element of $str_arr */
33for($index = 0; $index < count($str_arr); $index++) {
34  echo "-- Iteration $count --\n";
35
36  $str = $str_arr[$index];  //getting the array element in 'str' variable
37
38  //strtr() call in three args syntax form
39  var_dump( strtr($str, $from, $to) );
40
41  //strtr() call in two args syntax form
42  var_dump( strtr($str, $replace_pairs) );
43
44  $count++;
45}
46echo "*** Done ***";
47?>
48--EXPECT--
49*** Testing strtr() : empty string & null for 'str' arg ***
50-- Iteration 1 --
51string(0) ""
52string(0) ""
53-- Iteration 2 --
54string(0) ""
55string(0) ""
56-- Iteration 3 --
57string(0) ""
58string(0) ""
59-- Iteration 4 --
60string(0) ""
61string(0) ""
62-- Iteration 5 --
63string(0) ""
64string(0) ""
65*** Done ***
66