3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sections = array( array( 'name' => 'home', 'uri' => '/', 'title' => 'home'), array( 'name' => 'tech', 'uri' => '/tech', 'title' => 'ux/ui' ), array( 'name' => 'monetization', 'uri' => '/monetization', 'title' => 'monetization' ), array( 'name' => 'contact', 'uri' => '/contact', 'title' => 'contact', 'callToAction' => true, 'desktopTitle' => 'contact us' ), array( 'name' => 'blog', 'uri' => 'https://blog.marfeel.com/blog', 'title' => 'blog', 'external' => true), ); function callToActions($section) { return $section["callToAction"]; } function defaultSections($section) { return !$section["callToAction"]; } function buildSections ($sections) { $index = count($sections); while($index) { $section = $sections[--$index]; echo '<li class="' . (getCurrentSection() == $section["name"] ? "mrf-current" : "") . (($section["callToAction"])? " mrf-contactAction": "") .'"> <a href="' . get_bloginfo('wpurl') . $section["uri"] . '">' . ($section["desktopTitle"]? ucfirst($section["desktopTitle"]): ucfirst($section["title"])) . '</a> </li>'; } } buildSections(array_filter($sections, callToActions)); //print_r(array_filter($sections, defaultSections));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught Error: Undefined constant "callToActions" in /in/MtH9c:32 Stack trace: #0 {main} thrown in /in/MtH9c on line 32
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Warning: Use of undefined constant callToActions - assumed 'callToActions' (this will throw an Error in a future version of PHP) in /in/MtH9c on line 32 Notice: Undefined index: callToAction in /in/MtH9c on line 12 Notice: Undefined index: callToAction in /in/MtH9c on line 12 Notice: Undefined index: callToAction in /in/MtH9c on line 12 Notice: Undefined index: callToAction in /in/MtH9c on line 12 Notice: Undefined offset: 0 in /in/MtH9c on line 24 Fatal error: Uncaught Error: Call to undefined function getCurrentSection() in /in/MtH9c:26 Stack trace: #0 /in/MtH9c(32): buildSections(Array) #1 {main} thrown in /in/MtH9c on line 26
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Warning: Use of undefined constant callToActions - assumed 'callToActions' (this will throw an Error in a future version of PHP) in /in/MtH9c on line 32 Fatal error: Uncaught Error: Call to undefined function getCurrentSection() in /in/MtH9c:26 Stack trace: #0 /in/MtH9c(32): buildSections(Array) #1 {main} thrown in /in/MtH9c on line 26
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25
Notice: Use of undefined constant callToActions - assumed 'callToActions' in /in/MtH9c on line 32 Notice: Undefined index: callToAction in /in/MtH9c on line 12 Notice: Undefined index: callToAction in /in/MtH9c on line 12 Notice: Undefined index: callToAction in /in/MtH9c on line 12 Notice: Undefined index: callToAction in /in/MtH9c on line 12 Notice: Undefined offset: 0 in /in/MtH9c on line 24 Fatal error: Uncaught Error: Call to undefined function getCurrentSection() in /in/MtH9c:26 Stack trace: #0 /in/MtH9c(32): buildSections(Array) #1 {main} thrown in /in/MtH9c on line 26
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Notice: Use of undefined constant callToActions - assumed 'callToActions' in /in/MtH9c on line 32 Notice: Undefined index: callToAction in /in/MtH9c on line 12 Notice: Undefined index: callToAction in /in/MtH9c on line 12 Notice: Undefined index: callToAction in /in/MtH9c on line 12 Notice: Undefined index: callToAction in /in/MtH9c on line 12 Notice: Undefined offset: 0 in /in/MtH9c on line 24 Fatal error: Call to undefined function getCurrentSection() in /in/MtH9c on line 26
Process exited with code 255.

preferences:
150.27 ms | 402 KiB | 194 Q