From: Mischa POSLAWSKY Date: Sat, 16 Sep 2017 13:57:10 +0000 (+0200) Subject: page: unconditional declaration of getoutput() X-Git-Tag: v2.2~8 X-Git-Url: http://git.shiar.net/minimedit.git/commitdiff_plain/4e1394082f1446017534b9c3d423a35d483da6ab page: unconditional declaration of getoutput() Move up front to allow usage in fail() error handler. --- 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"; }