global statement removal: hphp/test/zend [2/x]
[hiphop-php.git] / hphp / test / zend / good / ext / iconv / tests / iconv_get_encoding_error.php
blobff19ab717a80f6960bcc8e2df30241fa9891c11c
1 <?php
2 /* Prototype : mixed iconv_get_encoding([string type])
3 * Description: Get internal encoding and output encoding for ob_iconv_handler()
4 * Source code: ext/iconv/iconv.c
5 */
7 /*
8 * Test Error functionality of iconv_get_encoding
9 */
11 echo "*** Testing iconv_get_encoding() : error functionality ***\n";
13 //get an unset variable
14 $unset_var = 10;
15 unset ($unset_var);
17 // get a class
18 class classA
20 public function __toString() {
21 return "UTF-8";
25 // heredoc string
26 $heredoc = <<<EOT
27 Nothing
28 EOT;
30 // get a resource variable
31 $fp = fopen(__FILE__, "r");
33 // unexpected values to be passed to $encoding argument
34 $inputs = array(
36 // int data
37 /*1*/ 0,
39 12345,
40 -2345,
42 // float data
43 /*5*/ 10.5,
44 -10.5,
45 12.3456789000e10,
46 12.3456789000E-10,
47 .5,
49 // null data
50 /*10*/ NULL,
51 null,
53 // boolean data
54 /*12*/ true,
55 false,
56 TRUE,
57 FALSE,
59 // empty data
60 /*16*/ "",
61 '',
63 // invalid string data
64 /*18*/ "Nothing",
65 'Nothing',
66 $heredoc,
68 // object data
69 /*21*/ new classA(),
71 // undefined data
72 /*22*/ @$undefined_var,
74 // unset data
75 /*23*/ @$unset_var,
77 // resource variable
78 /*24*/ $fp
81 // loop through each element of $inputs to check the behavior of mb_regex_encoding()
82 $iterator = 1;
83 foreach($inputs as $input) {
84 echo "\n-- Iteration $iterator --\n";
85 try { var_dump( iconv_get_encoding($input) ); } catch (Exception $e) { echo "\n".'Warning: '.$e->getMessage().' in '.__FILE__.' on line '.__LINE__."\n"; }
86 $iterator++;
89 fclose($fp);
91 echo "Done";