import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-strings / strtr_variation5.php
blob96ff95d4775ed24b9054840dc694ae8d9519450a
1 <?php
2 /* Prototype : string strtr(string $str, string $from[, string $to]);
3 string strtr(string $str, array $replace_pairs);
4 * Description: Translates characters in str using given translation tables
5 * Source code: ext/standard/string.c
6 */
8 /* Test strtr() function: with unexpected inputs for 'str'
9 * and expected type for 'from' & 'to' arguments
12 echo "*** Testing strtr() function: with unexpected inputs for 'str' ***\n";
14 //get an unset variable
15 $unset_var = 'string_val';
16 unset($unset_var);
18 //defining a class
19 class sample {
20 public function __toString() {
21 return "sample object";
25 //getting the resource
26 $file_handle = fopen(__FILE__, "r");
28 // array with different values
29 $strings = array (
31 // integer values
32 /*1*/ 0,
34 -2,
36 // float values
37 /*4*/ 10.5,
38 -20.5,
39 10.1234567e10,
41 // array values
42 /*7*/ array(),
43 array(0),
44 array(1, 2),
46 // boolean values
47 /*10*/ true,
48 false,
49 TRUE,
50 FALSE,
52 // null vlaues
53 /*14*/ NULL,
54 null,
56 // objects
57 /*16*/ new sample(),
59 // resource
60 /*17*/ $file_handle,
62 // undefined variable
63 /*18*/ @$undefined_var,
65 // unset variable
66 /*19*/ @$unset_var
69 //defining 'from' argument
70 $from = "012atm";
72 //defining 'to' argument
73 $to = "atm012";
75 // loop through with each element of the $strings array to test strtr() function
76 $count = 1;
77 for($index = 0; $index < count($strings); $index++) {
78 echo "-- Iteration $count --\n";
79 $str = $strings[$index];
80 var_dump( strtr($str, $from, $to) );
81 $count ++;
84 fclose($file_handle); //closing the file handle
87 ===DONE===