3v4l.org

run code in 300+ PHP versions simultaneously
<?php # It is NOT OK to start reading past the end of the string, no, no. Bad programmer. var_dump(substr("a", 1)); # But it is OK to ask for a bigger slice than the length of the string. var_dump(substr("a", 0, 10)); # It is also OK to read past the begining of the string, why not. var_dump(substr("a", -1)); var_dump(substr("a", -2)); # On the other hand, it is NOT OK to stop reading before the end of the string. Bad programmer. var_dump(substr("a", 0, -2));

preferences:
26.22 ms | 405 KiB | 5 Q