From 4e1394082f1446017534b9c3d423a35d483da6ab Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sat, 16 Sep 2017 15:57:10 +0200 Subject: [PATCH] page: unconditional declaration of getoutput() Move up front to allow usage in fail() error handler. --- page.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/page.php b/page.php index 8b264bf..e8023ff 100644 --- a/page.php +++ b/page.php @@ -2,6 +2,18 @@ error_reporting(E_ALL); ini_set('display_errors', TRUE); +function getoutput($blocks = []) +{ + $rep = []; + foreach ($blocks as $name => $html) { + $rep["[[$name]]"] = sprintf('%s', + is_numeric($name) ? '' : "[[$name]]", + preg_replace('{}', '', $html) + ); + } + return str_replace(array_keys($rep), array_values($rep), ob_get_clean()); +} + function fail($error) { http_response_code(500); @@ -61,18 +73,6 @@ print "\n\n"; # execute dynamic code if ($Page) { - function getoutput($blocks = []) - { - $rep = []; - foreach ($blocks as $name => $html) { - $rep["[[$name]]"] = sprintf('%s', - is_numeric($name) ? '' : "[[$name]]", - preg_replace('{}', '', $html) - ); - } - return str_replace(array_keys($rep), array_values($rep), ob_get_clean()); - } - $found |= require "./$Page.php"; } -- 2.30.0