1--TEST--
2Test strrpos() function : basic functionality - with all arguments
3--FILE--
4<?php
5/* Prototype  : int strrpos ( string $haystack, string $needle [, int $offset] );
6 * Description: Find position of last occurrence of 'needle' in 'haystack'
7 * Source code: ext/standard/string.c
8*/
9
10echo "*** Testing strrpos() function: basic functionality ***\n";
11$heredoc_str = <<<EOD
12Hello, World
13EOD;
14
15echo "-- With all arguments --\n";
16//regular string for haystack & needle, with various offsets
17var_dump( strrpos("Hello, World", "Hello", 0) );
18var_dump( strrpos("Hello, World", 'Hello', 1) );
19var_dump( strrpos('Hello, World', 'World', 1) );
20var_dump( strrpos('Hello, World', "World", 5) );
21
22//heredoc string for haystack & needle, with various offsets
23var_dump( strrpos($heredoc_str, "Hello, World", 0) );
24var_dump( strrpos($heredoc_str, 'Hello', 0) );
25var_dump( strrpos($heredoc_str, 'Hello', 1) );
26var_dump( strrpos($heredoc_str, $heredoc_str, 0) );
27var_dump( strrpos($heredoc_str, $heredoc_str, 1) );
28
29//various offsets
30var_dump( strrpos("Hello, World", "o", 3) );
31var_dump( strrpos("Hello, World", "o", 6) );
32var_dump( strrpos("Hello, World", "o", 10) );
33echo "*** Done ***";
34?>
35--EXPECT--
36*** Testing strrpos() function: basic functionality ***
37-- With all arguments --
38int(0)
39bool(false)
40int(7)
41int(7)
42int(0)
43int(0)
44bool(false)
45int(0)
46bool(false)
47int(8)
48int(8)
49bool(false)
50*** Done ***
51