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.14, 8.5.0
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.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.28
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:
58.4 ms | 409 KiB | 5 Q