1--TEST--
2Test strrchr() function : basic functionality
3--FILE--
4<?php
5echo "*** Testing strrchr() function: basic functionality ***\n";
6var_dump( strrchr("Hello, World", "H") ); //needle as single char
7var_dump( strrchr("Hello, World", "H", true) ); //needle as single char
8var_dump( strrchr("Hello, World", "Hello") ); //needle as a first word of haystack
9var_dump( strrchr("Hello, World", "Hello", true) ); //needle as a first word of haystack
10var_dump( strrchr('Hello, World', 'H') );
11var_dump( strrchr('Hello, World', 'H', true) );
12var_dump( strrchr('Hello, World', 'Hello') );
13var_dump( strrchr('Hello, World', 'Hello', true) );
14
15//considering case
16var_dump( strrchr("Hello, World", "h") );
17var_dump( strrchr("Hello, World", "h", true) );
18var_dump( strrchr("Hello, World", "hello") );
19var_dump( strrchr("Hello, World", "hello", true) );
20
21//needle as second word of haystack
22var_dump( strrchr("Hello, World", "World") );
23var_dump( strrchr("Hello, World", "World", true) );
24var_dump( strrchr('Hello, World', 'World') );
25var_dump( strrchr('Hello, World', 'World', true) );
26
27//needle as special char
28var_dump( strrchr("Hello, World", ",") );
29var_dump( strrchr("Hello, World", ",", true) );
30var_dump( strrchr('Hello, World', ',') );
31var_dump( strrchr('Hello, World', ',', true) );
32
33var_dump( strrchr("Hello, World", "Hello, World") ); //needle as haystack
34var_dump( strrchr("Hello, World", "Hello, World", true) ); //needle as haystack
35
36//needle string containing one existing and one non-existing char
37var_dump( strrchr("Hello, World", "Hi") );
38var_dump( strrchr("Hello, World", "Hi", true) );
39
40//multiple existence of needle in haystack
41var_dump( strrchr("Hello, World", "o") );
42var_dump( strrchr("Hello, World", "o", true) );
43var_dump( strrchr("Hello, World", "ooo") );
44var_dump( strrchr("Hello, World", "ooo", true) );
45
46var_dump( strrchr("Hello, World", "Zzzz") ); //non-existent needle in haystack
47var_dump( strrchr("Hello, World", "Zzzz", true) ); //non-existent needle in haystack
48echo "*** Done ***";
49?>
50--EXPECT--
51*** Testing strrchr() function: basic functionality ***
52string(12) "Hello, World"
53string(0) ""
54string(12) "Hello, World"
55string(0) ""
56string(12) "Hello, World"
57string(0) ""
58string(12) "Hello, World"
59string(0) ""
60bool(false)
61bool(false)
62bool(false)
63bool(false)
64string(5) "World"
65string(7) "Hello, "
66string(5) "World"
67string(7) "Hello, "
68string(7) ", World"
69string(5) "Hello"
70string(7) ", World"
71string(5) "Hello"
72string(12) "Hello, World"
73string(0) ""
74string(12) "Hello, World"
75string(0) ""
76string(4) "orld"
77string(8) "Hello, W"
78string(4) "orld"
79string(8) "Hello, W"
80bool(false)
81bool(false)
82*** Done ***
83