global statement removal: hphp/test/zend [2/x]
[hiphop-php.git] / hphp / test / zend / good / ext / iconv / tests / iconv_mime_decode_headers_variation2.php
blob68283d228bb35442807681cf7f79ed73262db1c7
1 <?php
2 /* Prototype : array iconv_mime_decode_headers(string headers [, int mode, string charset])
3 * Description: Decodes multiple mime header fields
4 * Source code: ext/iconv/iconv.c
5 */
7 /*
8 * Pass different data types to $str argument to see how iconv_mime_decode_headers() behaves
9 */
11 echo "*** Testing iconv_mime_decode_headers() : usage variations ***\n";
13 // Initialise function arguments not being substituted
14 $headers = <<<EOF
15 Subject: =?UTF-8?B?QSBTYW1wbGUgVGVzdA==?=
16 To: example@example.com
17 Date: Thu, 1 Jan 1970 00:00:00 +0000
18 Message-Id: <example@example.com>
19 Received: from localhost (localhost [127.0.0.1]) by localhost
20 with SMTP id example for <example@example.com>;
21 Thu, 1 Jan 1970 00:00:00 +0000 (UTC)
22 (envelope-from example-return-0000-example=example.com@example.com)
23 Received: (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000
25 EOF;
27 $mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR;
28 $charset = 'UTF-8';
31 //get an unset variable
32 $unset_var = 10;
33 unset ($unset_var);
35 // get a class
36 class classA
38 public function __toString() {
39 return "Class A object";
43 // heredoc string
44 $heredoc = <<<EOT
45 hello world
46 EOT;
48 // get a resource variable
49 $fp = fopen(__FILE__, "r");
51 // unexpected values to be passed to $str argument
52 $inputs = array(
54 // int data
55 /*1*/ 0,
57 12345,
58 -2345,
60 // float data
61 /*5*/ 10.5,
62 -10.5,
63 12.3456789000e10,
64 12.3456789000E-10,
65 .5,
67 // null data
68 /*10*/ NULL,
69 null,
71 // boolean data
72 /*12*/ true,
73 false,
74 TRUE,
75 FALSE,
77 // empty data
78 /*16*/ "",
79 '',
81 // string data
82 /*18*/ "string",
83 'string',
84 $heredoc,
86 // object data
87 /*21*/ new classA(),
89 // undefined data
90 /*22*/ @$undefined_var,
92 // unset data
93 /*23*/ @$unset_var,
95 // resource variable
96 /*24*/ $fp
99 // loop through each element of $inputs to check the behavior of iconv_mime_decode_headers()
100 $iterator = 1;
101 foreach($inputs as $input) {
102 echo "\n-- Iteration $iterator --\n";
103 try { var_dump( iconv_mime_decode_headers($headers, $input, $charset)); } catch (Exception $e) { echo "\n".'Warning: '.$e->getMessage().' in '.__FILE__.' on line '.__LINE__."\n"; }
104 $iterator++;
107 fclose($fp);
109 echo "Done";