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  NULL,
23  null,
24  FALSE,
25  false,
26  $heredoc_str
27);
28
29$from = "";
30$to = "TEST";
31$replace_pairs = array("" => "t", '' => "TEST");
32
33
34/* loop through to test strtr() with each element of $str_arr */
35for($index = 0; $index < count($str_arr); $index++) {
36  echo "-- Iteration $count --\n";
37
38  $str = $str_arr[$index];  //getting the array element in 'str' variable
39
40  //strtr() call in three args syntax form
41  var_dump( strtr($str, $from, $to) );
42
43  //strtr() call in two args syntax form
44  var_dump( strtr($str, $replace_pairs) );
45
46  $count++;
47}
48echo "*** Done ***";
49?>
50--EXPECT--
51*** Testing strtr() : empty string & null for 'str' arg ***
52-- Iteration 1 --
53string(0) ""
54string(0) ""
55-- Iteration 2 --
56string(0) ""
57string(0) ""
58-- Iteration 3 --
59string(0) ""
60string(0) ""
61-- Iteration 4 --
62string(0) ""
63string(0) ""
64-- Iteration 5 --
65string(0) ""
66string(0) ""
67-- Iteration 6 --
68string(0) ""
69string(0) ""
70-- Iteration 7 --
71string(0) ""
72string(0) ""
73*** Done ***
74