From 4c2a8b005044c501594cb413f33b7e0dca7bc7b7 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Thu, 13 Mar 2025 17:33:42 +0100 Subject: [PATCH] Compile: Move ?>\n?|\\?>\n?<\\?php~", '', $file); $file = php_shrink($file); $filename = $project . (preg_match('~-dev$~', $VERSION) ? "" : "-$VERSION") . ($driver ? "-$driver" : "") . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php"; diff --git a/php_shrink.inc.php b/php_shrink.inc.php index f127493d..fe3b1c18 100644 --- a/php_shrink.inc.php +++ b/php_shrink.inc.php @@ -13,6 +13,7 @@ */ function php_shrink($input) { // based on http://latrine.dgx.cz/jak-zredukovat-php-skripty + $input = preg_replace("~<\\?php\\s*\\?>\n?|\\?>\n?<\\?php~", '', $input); $special_variables = array_flip(array('$this', '$GLOBALS', '$_GET', '$_POST', '$_FILES', '$_COOKIE', '$_SESSION', '$_SERVER', '$http_response_header', '$php_errormsg')); $short_variables = array(); $shortening = true; diff --git a/tests/php_shrink.php b/tests/php_shrink.php index 38faff32..95292b44 100644 --- a/tests/php_shrink.php +++ b/tests/php_shrink.php @@ -33,3 +33,4 @@ check('$ab = 1; echo "$ab";', '$a=1;echo"$a";'); check('echo 1; echo 3;', 'echo 1,3;'); check('echo 1; ?>2