3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php define(DS, '/'); $server_path = "/test1/test2/"; $server_path = str_replace(array('/', '\\'), DS, $server_path); $next_server_path = substr($server_path, 0, strrpos($server_path, DS)); var_dump($next_server_path); $server_path = "/test1/test2"; $server_path = str_replace(array('/', '\\'), DS, $server_path); $next_server_path = substr($server_path, 0, strrpos($server_path, DS)); var_dump($next_server_path);
based on gDmta
Output for 4.3.0 - 7.1.0
Notice: Use of undefined constant DS - assumed 'DS' in /in/qqb2Q on line 2 string(12) "/test1/test2" string(6) "/test1"