3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** Ejemplo pàra post: https://trasweb.net/blog/optimizacion-web/optimizacion-de-funciones-php */ $vista = new stdclass; function get_menu() { static $cache = null; if(isset($cache) ) return $cache; error_log('Se inicia la creación de menú'); $menu[] = ['title' => 'Inicio', 'href' => '/']; $menu[] = ['title' => 'Servicios', 'href' => '/servicios']; $menu[] = ['title' => 'Quiénes somos', 'href' => '/quienes-somos']; $menu[] = ['title' => 'Blog', 'href' => '/blog']; $menu[] = ['title' => 'Contacto', 'href' => '/contacto']; error_log('Se finaliza la creación de menú'); return $cache = $menu; } if(!empty(get_menu()) ) { $vista->menu = get_menu(); $vista->menu_inferior = get_menu(); $vista->template = 'vista_con_menu'; }else { $vista->template = 'vista_sin_menu'; }

preferences:
32.69 ms | 402 KiB | 5 Q