1--TEST--
2Test stripos() function : usage variations - null terminated strings for 'haystack' argument
3--FILE--
4<?php
5/* Prototype  : int stripos ( string $haystack, string $needle [, int $offset] );
6 * Description: Find position of first occurrence of a case-insensitive string
7 * Source code: ext/standard/string.c
8*/
9
10/* Test stripos() function with null terminated strings for 'haystack' argument
11 *  in order to check the binary safe
12*/
13
14echo "*** Test stripos() function: binary safe ***\n";
15$haystacks = array(
16  "Hello".chr(0)."World",
17  chr(0)."Hello World",
18  "Hello World".chr(0),
19  chr(0).chr(0).chr(0),
20  "Hello\0world",
21  "\0Hello",
22  "Hello\0"
23);
24
25for($index = 0; $index < count($haystacks); $index++ ) {
26  var_dump( stripos($haystacks[$index], "\0") );
27  var_dump( stripos($haystacks[$index], "\0", $index) );
28}
29echo "*** Done ***";
30?>
31--EXPECTF--
32*** Test stripos() function: binary safe ***
33int(5)
34int(5)
35int(0)
36bool(false)
37int(11)
38int(11)
39int(0)
40bool(false)
41int(5)
42int(5)
43int(0)
44bool(false)
45int(5)
46bool(false)
47*** Done ***
48