xref: /PHP-8.1/ext/standard/tests/strings/ltrim.phpt (revision b10416a6)
1--TEST--
2Test ltrim() function
3--FILE--
4<?php
5
6/*  Testing for Error conditions  */
7
8/*  Invalid Number of Arguments */
9
10 echo "\n *** Output for Error Conditions ***\n";
11
12/* heredoc string */
13$str = <<<EOD
14us
15ing heredoc string
16EOD;
17
18echo "\n *** Using heredoc string ***\n";
19var_dump( ltrim($str, "\nusi") );
20
21/* Testing the Normal behaviour of ltrim() function */
22
23 echo "\n *** Output for Normal Behaviour ***\n";
24 var_dump ( ltrim(" \t\0    ltrim test") );                      /* without second Argument */
25 var_dump ( ltrim("   ltrim test" , "") );                       /* no characters in second Argument */
26 var_dump ( ltrim("        ltrim test", true) );                 /* with boolean value as second Argument */
27 var_dump ( ltrim("        ltrim test", " ") );                  /* with single space as second Argument */
28 var_dump ( ltrim("\t\n\r\0\x0B ltrim test", "\t\n\r\0\x0B") );  /* with multiple escape sequences as second Argument */
29 var_dump ( ltrim("ABCXYZltrim test", "A..Z") );                 /* with characters range as second Argument */
30 var_dump ( ltrim("0123456789ltrim test", "0..9") );             /* with numbers range as second Argument */
31 var_dump ( ltrim("@$#ltrim test", "#@$") );                     /* with some special characters as second Argument */
32
33
34echo "\n *** Output for  scalar argument) ***\n";
35var_dump( ltrim(  12345  ) );                                   /* Scalar argument */
36
37echo "\nDone\n";
38
39?>
40--EXPECT--
41*** Output for Error Conditions ***
42
43 *** Using heredoc string ***
44string(17) "ng heredoc string"
45
46 *** Output for Normal Behaviour ***
47string(10) "ltrim test"
48string(13) "   ltrim test"
49string(18) "        ltrim test"
50string(10) "ltrim test"
51string(11) " ltrim test"
52string(10) "ltrim test"
53string(10) "ltrim test"
54string(10) "ltrim test"
55
56 *** Output for  scalar argument) ***
57string(5) "12345"
58
59Done
60