global statement removal: hphp/test/zend [2/x]
[hiphop-php.git] / hphp / test / zend / good / ext / iconv / tests / iconv_mime_decode_variation2.php
blob42695689fde43f430cf5ed84bd57151ece430e9a
1 <?php
2 /* Prototype : string iconv_mime_decode(string encoded_string [, int mode, string charset])
3 * Description: Decodes a mime header field
4 * Source code: ext/iconv/iconv.c
5 */
7 /*
8 * Pass different data types to $str argument to see how iconv_mime_decode() behaves
9 */
11 echo "*** Testing iconv_mime_decode() : usage variations ***\n";
13 // Initialise function arguments not being substituted
14 $header = b'Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=';
15 $mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR;
16 $charset = 'UTF-8';
19 //get an unset variable
20 $unset_var = 10;
21 unset ($unset_var);
23 // get a class
24 class classA
26 public function __toString() {
27 return "Class A object";
31 // heredoc string
32 $heredoc = <<<EOT
33 hello world
34 EOT;
36 // get a resource variable
37 $fp = fopen(__FILE__, "r");
39 // unexpected values to be passed to $str argument
40 $inputs = array(
42 // int data
43 /*1*/ 0,
45 12345,
46 -2345,
48 // float data
49 /*5*/ 10.5,
50 -10.5,
51 12.3456789000e10,
52 12.3456789000E-10,
53 .5,
55 // null data
56 /*10*/ NULL,
57 null,
59 // boolean data
60 /*12*/ true,
61 false,
62 TRUE,
63 FALSE,
65 // empty data
66 /*16*/ "",
67 '',
69 // string data
70 /*18*/ "string",
71 'string',
72 $heredoc,
74 // object data
75 /*21*/ new classA(),
77 // undefined data
78 /*22*/ @$undefined_var,
80 // unset data
81 /*23*/ @$unset_var,
83 // resource variable
84 /*24*/ $fp
87 // loop through each element of $inputs to check the behavior of iconv_mime_decode()
88 $iterator = 1;
89 foreach($inputs as $input) {
90 echo "\n-- Iteration $iterator --\n";
91 try { var_dump( bin2hex(iconv_mime_decode($header, $input, $charset))); } catch (Exception $e) { echo "\n".'Warning: '.$e->getMessage().' in '.__FILE__.' on line '.__LINE__."\n"; }
92 $iterator++;
95 fclose($fp);
97 echo "Done";