3v4l.org

run code in 300+ PHP versions simultaneously
<?php function cleanSniffClass($sniffClass) { $newName = strtolower($sniffClass); var_dump(strlen($newName)); var_dump(strrpos($newName, '\sniffs\\')); $end = (strlen($newName) - strrpos($newName, '\sniffs\\') + 1); var_dump($end); $start = strrpos($newName, '\\', ($end * -1)); var_dump($start); $newName = substr($newName, ($start + 1)); var_dump($newName); return $newName; } var_dump(cleanSniffClass('X\A\Sniffs\Cat\Name')); var_dump(cleanSniffClass('PHPCompatibility\Sniffs\Cat\Name'));
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.1.29 - 8.1.30, 8.2.0 - 8.2.17, 8.2.19 - 8.2.25, 8.3.0 - 8.3.13
int(19) int(3) int(17) int(1) string(17) "a\sniffs\cat\name" string(17) "a\sniffs\cat\name" int(32) int(16) int(17) bool(false) string(31) "hpcompatibility\sniffs\cat\name" string(31) "hpcompatibility\sniffs\cat\name"
Output for 8.2.18
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.2.18/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.2.18/modules/sodium.so.so (/usr/lib/php/8.2.18/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 int(19) int(3) int(17) int(1) string(17) "a\sniffs\cat\name" string(17) "a\sniffs\cat\name" int(32) int(16) int(17) bool(false) string(31) "hpcompatibility\sniffs\cat\name" string(31) "hpcompatibility\sniffs\cat\name"
Output for 8.1.28
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.1.28/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.1.28/modules/sodium.so.so (/usr/lib/php/8.1.28/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 int(19) int(3) int(17) int(1) string(17) "a\sniffs\cat\name" string(17) "a\sniffs\cat\name" int(32) int(16) int(17) bool(false) string(31) "hpcompatibility\sniffs\cat\name" string(31) "hpcompatibility\sniffs\cat\name"

preferences:
72.28 ms | 408 KiB | 5 Q