3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function remove_index_etc($url) { if (preg_match('/(?:\/(?:home|default|index)\..{3,4}\*)',$url)) { $url = preg_replace('/^(.*)(\/(?:home|default|index)\..{3,4}\*)(.*)$/i', "$1$2$3", $url); } else { $url = preg_replace('/^(.*)(?:\/(?:home|default|index)\..{3,4})([\?\/#]+.*)?$/i', "$1$2", $url); } return $url; } echo remove_index_etc("http://a.com/index.html") . PHP_EOL; echo remove_index_etc("http://a.com/index.html*"). PHP_EOL; echo remove_index_etc("http://a.com/*index.html*"). PHP_EOL; echo remove_index_etc("http://a.com/*index.html*?a=1"). PHP_EOL; echo remove_index_etc("http://a.com/*index.html*?a=1"). PHP_EOL; echo remove_index_etc("http://a.com/*index.html*a=1*"). PHP_EOL; echo remove_index_etc("http://a.com/index.html/*"). PHP_EOL; echo remove_index_etc("http://a.com/index.html?a=1"). PHP_EOL; echo remove_index_etc("http://a.com/index.html?a=1*"). PHP_EOL; echo remove_index_etc("http://a.com/index.html*a=1"). PHP_EOL; echo remove_index_etc("http://a.com/*"). PHP_EOL; echo remove_index_etc("http://a.com"). PHP_EOL; echo remove_index_etc("http://a.com/index.html/?a=1*"). PHP_EOL; echo remove_index_etc("http://a.com/index.html#a=1*"). PHP_EOL; echo remove_index_etc("http://a.com#index.html?a=1"). PHP_EOL; echo remove_index_etc("http://a.com#index.html?a=1*"). PHP_EOL;
Output for 4.3.11 - 4.4.9, 5.0.2 - 5.6.28, 7.0.0 - 7.1.0
Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/index.html* Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/*index.html* Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/*index.html*?a=1 Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/*index.html*?a=1 Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/*index.html*a=1* Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/* Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com?a=1 Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com?a=1* Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/index.html*a=1 Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/* Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/?a=1* Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com#a=1* Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com#index.html?a=1 Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com#index.html?a=1*
Output for hhvm-3.10.0 - 3.12.0
Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com/index.html* Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com/*index.html* Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com/*index.html*?a=1 Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com/*index.html*?a=1 Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com/*index.html*a=1* Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com/* Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com?a=1 Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com?a=1* Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com/index.html*a=1 Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com/* Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com/?a=1* Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com#a=1* Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com#index.html?a=1 Warning: No ending delimiter '/' found: [/(?:\/(?:home|default|index)\..{3,4}\*)] in /in/Bc2Ns on line 5 http://a.com#index.html?a=1*
Output for 5.0.0 - 5.0.1
Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 16 http://a.comPHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 17 http://a.com/index.html*PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 18 http://a.com/*index.html*PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 19 http://a.com/*index.html*?a=1PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 20 http://a.com/*index.html*?a=1PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 21 http://a.com/*index.html*a=1*PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 22 http://a.com/*PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 23 http://a.com?a=1PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 24 http://a.com?a=1*PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 25 http://a.com/index.html*a=1PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 26 http://a.com/*PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 27 http://a.comPHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 28 http://a.com/?a=1*PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 29 http://a.com#a=1*PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 30 http://a.com#index.html?a=1PHP_EOL Warning: preg_match(): No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 31 http://a.com#index.html?a=1*PHP_EOL
Output for 4.3.10
Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/index.html* Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/*index.html* Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/*index.html*?a=1 Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/*index.html*?a=1 Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/*index.html*a=1* Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/* Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com?a=1 Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com?a=1* Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/index.html*a=1 Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/* Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com/?a=1* Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com#a=1* Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com#index.html?a=1 Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 http://a.com#index.html?a=1*
Output for 4.3.0 - 4.3.9
Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 16 http://a.comPHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 17 http://a.com/index.html*PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 18 http://a.com/*index.html*PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 19 http://a.com/*index.html*?a=1PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 20 http://a.com/*index.html*?a=1PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 21 http://a.com/*index.html*a=1*PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 22 http://a.com/*PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 23 http://a.com?a=1PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 24 http://a.com?a=1*PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 25 http://a.com/index.html*a=1PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 26 http://a.com/*PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 27 http://a.comPHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 28 http://a.com/?a=1*PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 29 http://a.com#a=1*PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 30 http://a.com#index.html?a=1PHP_EOL Warning: No ending delimiter '/' found in /in/Bc2Ns on line 5 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/Bc2Ns on line 31 http://a.com#index.html?a=1*PHP_EOL