xref: /PHP-8.1/ext/standard/tests/strings/trim.phpt (revision 3a4b8966)
1--TEST--
2trim(), rtrim() and ltrim() functions
3--FILE--
4<?php
5
6var_dump('ABC' ===  trim('ABC'));
7var_dump('ABC' === ltrim('ABC'));
8var_dump('ABC' === rtrim('ABC'));
9var_dump('ABC' ===  trim(" \0\t\nABC \0\t\n"));
10var_dump("ABC \0\t\n" === ltrim(" \0\t\nABC \0\t\n"));
11var_dump(" \0\t\nABC" === rtrim(" \0\t\nABC \0\t\n"));
12var_dump(" \0\t\nABC \0\t\n" ===  trim(" \0\t\nABC \0\t\n",''));
13var_dump(" \0\t\nABC \0\t\n" === ltrim(" \0\t\nABC \0\t\n",''));
14var_dump(" \0\t\nABC \0\t\n" === rtrim(" \0\t\nABC \0\t\n",''));
15var_dump("ABC\x50\xC1" === trim("ABC\x50\xC1\x60\x90","\x51..\xC0"));
16var_dump("ABC\x50" === trim("ABC\x50\xC1\x60\x90","\x51..\xC1"));
17var_dump("ABC" === trim("ABC\x50\xC1\x60\x90","\x50..\xC1"));
18var_dump("ABC\x50\xC1" === trim("ABC\x50\xC1\x60\x90","\x51..\xC0"));
19var_dump("ABC\x50" === trim("ABC\x50\xC1\x60\x90","\x51..\xC1"));
20var_dump("ABC" === trim("ABC\x50\xC1\x60\x90","\x50..\xC1"));
21
22?>
23--EXPECT--
24bool(true)
25bool(true)
26bool(true)
27bool(true)
28bool(true)
29bool(true)
30bool(true)
31bool(true)
32bool(true)
33bool(true)
34bool(true)
35bool(true)
36bool(true)
37bool(true)
38bool(true)
39