global statement removal: hphp/test/zend [2/x]
[hiphop-php.git] / hphp / test / zend / good / ext / iconv / tests / iconv_strrpos_variation2.php
blobd5e09eddd91d9e546d061281e174b0b1493f495e
1 <?php
2 /* Prototype : proto int iconv_strrpos(string haystack, string needle [, string charset])
3 * Description: Find position of last occurrence of a string within another
4 * Source code: ext/iconv/iconv.c
5 */
7 /*
8 * Pass iconv_strrpos() different data types as $needle argument to test behaviour
9 */
11 echo "*** Testing iconv_strrpos() : usage variations ***\n";
13 // Initialise function arguments not being substituted
14 $haystack = 'hello, world';
15 $encoding = 'utf-8';
17 //get an unset variable
18 $unset_var = 10;
19 unset ($unset_var);
21 // get a class
22 class classA
24 public function __toString() {
25 return "world";
29 // heredoc string
30 $heredoc = <<<EOT
31 world
32 EOT;
34 // get a resource variable
35 $fp = fopen(__FILE__, "r");
37 // unexpected values to be passed to $needle argument
38 $inputs = array(
40 // int data
41 /*1*/ 0,
43 12345,
44 -2345,
46 // float data
47 /*5*/ 10.5,
48 -10.5,
49 12.3456789000e10,
50 12.3456789000E-10,
51 .5,
53 // null data
54 /*10*/ NULL,
55 null,
57 // boolean data
58 /*12*/ true,
59 false,
60 TRUE,
61 FALSE,
63 // empty data
64 /*16*/ "",
65 '',
67 // string data
68 /*18*/ "world",
69 'world',
70 $heredoc,
72 // object data
73 /*21*/ new classA(),
75 // undefined data
76 /*22*/ @$undefined_var,
78 // unset data
79 /*23*/ @$unset_var,
81 // resource variable
82 /*24*/ $fp
85 // loop through each element of $inputs to check the behavior of iconv_strrpos()
86 $iterator = 1;
87 foreach($inputs as $input) {
88 echo "\n-- Iteration $iterator --\n";
89 try { var_dump( iconv_strrpos($haystack, $input, $encoding)); } catch (Exception $e) { echo "\n".'Warning: '.$e->getMessage().' in '.__FILE__.' on line '.__LINE__."\n"; }
90 $iterator++;
93 fclose($fp);
95 echo "Done";