3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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.38, hhvm-3.12.14 - 3.17.3, 7.0.0 - 7.3.1
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"