global statement removal: hphp/test/zend [2/x]
[hiphop-php.git] / hphp / test / zend / good / ext / iconv / tests / iconv_mime_decode_headers_variation3.php
blob150509905c9954f096bf4babb747618e48d5a73f
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 // Some of the parameters actually passed to charset will request to use
14 // a default charset determined by the platform. In order for this test to
15 // run on both linux and windows, the subject will have to be ascii only.
16 // Initialise function arguments not being substituted
17 $headers = <<<EOF
18 Subject: =?UTF-8?B?QSBTYW1wbGUgVGVzdA==?=
19 To: example@example.com
20 Date: Thu, 1 Jan 1970 00:00:00 +0000
21 Message-Id: <example@example.com>
22 Received: from localhost (localhost [127.0.0.1]) by localhost
23 with SMTP id example for <example@example.com>;
24 Thu, 1 Jan 1970 00:00:00 +0000 (UTC)
25 (envelope-from example-return-0000-example=example.com@example.com)
26 Received: (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000
28 EOF;
30 $mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR;
31 $charset = 'UTF-8';
34 //get an unset variable
35 $unset_var = 10;
36 unset ($unset_var);
38 // get a class
39 class classA
41 public function __toString() {
42 return "Class A object";
46 // heredoc string
47 $heredoc = <<<EOT
48 hello world
49 EOT;
51 // get a resource variable
52 $fp = fopen(__FILE__, "r");
54 // unexpected values to be passed to $str argument
55 $inputs = array(
57 // int data
58 /*1*/ 0,
60 12345,
61 -2345,
63 // float data
64 /*5*/ 10.5,
65 -10.5,
66 12.3456789000e10,
67 12.3456789000E-10,
68 .5,
70 // null data
71 /*10*/ NULL,
72 null,
74 // boolean data
75 /*12*/ true,
76 false,
77 TRUE,
78 FALSE,
80 // empty data
81 /*16*/ "",
82 '',
84 // string data
85 /*18*/ "string",
86 'string',
87 $heredoc,
89 // object data
90 /*21*/ new classA(),
92 // undefined data
93 /*22*/ @$undefined_var,
95 // unset data
96 /*23*/ @$unset_var,
98 // resource variable
99 /*24*/ $fp
102 // loop through each element of $inputs to check the behavior of iconv_mime_decode_headers()
103 $iterator = 1;
104 foreach($inputs as $input) {
105 echo "\n-- Iteration $iterator --\n";
106 try { var_dump( iconv_mime_decode_headers($headers, $input, $charset)); } catch (Exception $e) { echo "\n".'Warning: '.$e->getMessage().' in '.__FILE__.' on line '.__LINE__."\n"; }
107 $iterator++;
110 fclose($fp);
112 echo "Done";