3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = html_entity_decode('ABC&nbsp;'); $b = 'ABC '; echo 'Length with trim and nbsp: '.strlen(trim($a)).PHP_EOL; echo 'Length with trim and space: '.strlen(trim($b)).PHP_EOL; echo 'Length with mb_trim and nbsp: '.strlen(mb_trim($a)).PHP_EOL; echo 'Length with mb_trim and space: '.strlen(mb_trim($b)).PHP_EOL;
Output for 8.4.1 - 8.4.12
Length with trim and nbsp: 5 Length with trim and space: 3 Length with mb_trim and nbsp: 3 Length with mb_trim and space: 3
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.25
Length with trim and nbsp: 5 Length with trim and space: 3 Fatal error: Uncaught Error: Call to undefined function mb_trim() in /in/hMC7A:8 Stack trace: #0 {main} thrown in /in/hMC7A on line 8
Process exited with code 255.

preferences:
49.01 ms | 407 KiB | 5 Q