1--TEST--
2Test rtrim() function : error conditions
3--FILE--
4<?php
5
6/* Prototype  : string rtrim  ( string $str  [, string $charlist  ] )
7 * Description: Strip whitespace (or other characters) from the end of a string.
8 * Source code: ext/standard/string.c
9*/
10
11
12echo "*** Testing rtrim() : error conditions ***\n";
13
14echo "\n-- Testing rtrim() function with no arguments --\n";
15var_dump( rtrim() );
16
17echo "\n-- Testing rtrim() function with more than expected no. of arguments --\n";
18$extra_arg = 10;
19var_dump( rtrim("Hello World",  "Heo", $extra_arg) );
20
21
22$hello = "  Hello World\n";
23echo "\n-- Test rtrim function with various invalid charlists\n";
24var_dump(rtrim($hello, "..a"));
25var_dump(rtrim($hello, "a.."));
26var_dump(rtrim($hello, "z..a"));
27var_dump(rtrim($hello, "a..b..c"));
28
29?>
30===DONE===
31--EXPECTF--
32*** Testing rtrim() : error conditions ***
33
34-- Testing rtrim() function with no arguments --
35
36Warning: rtrim() expects at least 1 parameter, 0 given in %s on line %d
37NULL
38
39-- Testing rtrim() function with more than expected no. of arguments --
40
41Warning: rtrim() expects at most 2 parameters, 3 given in %s on line %d
42NULL
43
44-- Test rtrim function with various invalid charlists
45
46Warning: rtrim(): Invalid '..'-range, no character to the left of '..' in %s on line %d
47string(14) "  Hello World
48"
49
50Warning: rtrim(): Invalid '..'-range, no character to the right of '..' in %s on line %d
51string(14) "  Hello World
52"
53
54Warning: rtrim(): Invalid '..'-range, '..'-range needs to be incrementing in %s on line %d
55string(14) "  Hello World
56"
57
58Warning: rtrim(): Invalid '..'-range in %s on line %d
59string(14) "  Hello World
60"
61===DONE===
62