3v4l.org

run code in 300+ PHP versions simultaneously
<?php $directoryURI = $_SERVER['REQUEST_URI']; $path = parse_url($directoryURI, PHP_URL_PATH); $components = explode('/', $path); $first_part = $components[1]; ?> <ul id="mainnav"> <li class="<?php if ($first_part=="") {echo "active"; } ?>"><a href="#">Home</a></li> <li class="<?php if ($first_part=="tutorials") {echo "active"; } ?>"><a href="#">Tutorials</a></li> <li class="<?php if ($first_part=="resources") {echo "active"; } ?>"><a href="#">Resources</a></li> <li class="<?php if ($first_part=="library") {echo "active"; } ?>"><a href="#">Library</a></li> <li class="<?php if ($first_part=="our-projects") {echo "active"; } ?>"><a href="#">Our Projects</a></li> <li class="<?php if ($first_part=="community") {echo "active"; } ?>"><a href="#">Community</a></li> </ul>
Output for 8.1.23 - 8.1.27, 8.2.7 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined array key "REQUEST_URI" in /in/SLYo9 on line 3 Deprecated: parse_url(): Passing null to parameter #1 ($url) of type string is deprecated in /in/SLYo9 on line 4 Warning: Undefined array key 1 in /in/SLYo9 on line 6 <ul id="mainnav"> <li class="active"><a href="#">Home</a></li> <li class=""><a href="#">Tutorials</a></li> <li class=""><a href="#">Resources</a></li> <li class=""><a href="#">Library</a></li> <li class=""><a href="#">Our Projects</a></li> <li class=""><a href="#">Community</a></li> </ul>
Output for 7.4.3
Notice: Undefined index: REQUEST_URI in /in/SLYo9 on line 3 Notice: Undefined offset: 1 in /in/SLYo9 on line 6 <ul id="mainnav"> <li class="active"><a href="#">Home</a></li> <li class=""><a href="#">Tutorials</a></li> <li class=""><a href="#">Resources</a></li> <li class=""><a href="#">Library</a></li> <li class=""><a href="#">Our Projects</a></li> <li class=""><a href="#">Community</a></li> </ul>

preferences:
68.29 ms | 402 KiB | 28 Q