1--TEST--
2Test stripos() function : usage variations - null terminated strings for 'needle' 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 'needle' argument
11 *  in order to check binary safe
12*/
13
14echo "*** Test stripos() function: binary safe ***\n";
15$haystack = "\0Hello\0World\0";
16
17$needles = array(
18  "Hello".chr(0)."World",
19  chr(0)."Hello World",
20  "Hello World".chr(0),
21  chr(0).chr(0).chr(0),
22  "Hello\0world",
23  "\0Hello",
24  "Hello\0"
25);
26
27for($index = 0; $index < count($needles); $index++ ) {
28  var_dump( stripos($haystack, $needles[$index]) );
29  var_dump( stripos($haystack, $needles[$index], $index) );
30}
31echo "*** Done ***";
32?>
33--EXPECT--
34*** Test stripos() function: binary safe ***
35int(1)
36int(1)
37bool(false)
38bool(false)
39bool(false)
40bool(false)
41bool(false)
42bool(false)
43int(1)
44bool(false)
45int(0)
46bool(false)
47int(1)
48bool(false)
49*** Done ***
50