import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-strings / stripos_variation1.php
blob0a397ed5c1a77803a70f883c0d93a299aa05d3c2
1 <?php
2 /* Prototype : int stripos ( string $haystack, string $needle [, int $offset] );
3 * Description: Find position of first occurrence of a case-insensitive string
4 * Source code: ext/standard/string.c
5 */
7 /* Test stripos() function by passing double quoted strings for 'haystack' & 'needle' arguments */
9 echo "*** Testing stripos() function: with double quoted strings ***\n";
10 $haystack = "Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 ";
11 $needle = array(
12 //regular strings
13 "l",
14 "L",
15 "HELLO",
16 "hEllo",
18 //escape characters
19 "\t",
20 "\T", //invalid input
21 " ",
22 "\n",
23 "\N", //invalid input
25 ", //new line
27 //nulls
28 "\0",
29 NULL,
30 null,
32 //boolean false
33 FALSE,
34 false,
36 //empty string
37 "",
39 //special chars
40 " ",
41 "$",
42 " $",
43 "&",
44 "!#",
45 "%\o",
46 "\o,",
47 "()",
48 "*+",
49 "+",
50 "-",
51 ".",
52 ".;",
53 ":;",
54 ";",
55 "<=>",
56 ">",
57 "=>",
58 "?",
59 "@",
60 "@hEllo",
62 "12345", //decimal numeric string
63 "\x23", //hexadecimal numeric string
64 "#", //respective ASCII char of \x23
65 "\101", //octal numeric string
66 "A", //respective ASCII char of \101
67 "456HEE", //numerics + chars
68 $haystack //haystack as needle
71 /* loop through to get the position of the needle in haystack string */
72 $count = 1;
73 for($index=0; $index<count($needle); $index++) {
74 echo "-- Iteration $count --\n";
75 var_dump( stripos($haystack, $needle[$index]) );
76 var_dump( stripos($haystack, $needle[$index], $index) );
77 $count++;
79 echo "*** Done ***";