1--TEST-- 2Test strtr() function : basic functionality 3--FILE-- 4<?php 5echo "*** Testing strtr() : basic functionality ***\n"; 6//definitions of required input variables 7$trans1_arr = array("t" => "T", "e" => "E", "st" => "ST"); 8$trans2_arr = array('t' => 'T', 'e' => 'E', 'st' => 'ST'); 9$heredoc_str = <<<EOD 10test strtr 11EOD; 12 13//translating single char 14var_dump( strtr("test strtr", "t", "T") ); 15var_dump( strtr('test strtr', 't', 'T') ); 16var_dump( strtr($heredoc_str, "t", "T") ); 17 18//translating set of chars 19//$from and $to are of same length 20var_dump( strtr("test strtr", "test", "TEST") ); 21var_dump( strtr('test strtr', 'test', 'TEST') ); 22var_dump( strtr($heredoc_str, "test", "TEST") ); 23 24//$from and $to are of different lengths, extra chars in the longer one are ignored 25var_dump( strtr("test strtr", "test", "TESTz") ); 26var_dump( strtr('test strtr', 'testz', 'TEST') ); 27var_dump( strtr($heredoc_str, "test", "TESTz") ); 28 29//by using replace_pairs array 30var_dump( strtr("test strtr", $trans1_arr) ); 31var_dump( strtr('test strtr', $trans2_arr) ); 32var_dump( strtr($heredoc_str, $trans1_arr) ); 33echo "*** Done ***"; 34?> 35--EXPECT-- 36*** Testing strtr() : basic functionality *** 37string(10) "TesT sTrTr" 38string(10) "TesT sTrTr" 39string(10) "TesT sTrTr" 40string(10) "TEST STrTr" 41string(10) "TEST STrTr" 42string(10) "TEST STrTr" 43string(10) "TEST STrTr" 44string(10) "TEST STrTr" 45string(10) "TEST STrTr" 46string(10) "TEST STrTr" 47string(10) "TEST STrTr" 48string(10) "TEST STrTr" 49*** Done *** 50