From 42a72c02fa4b6a5eb9d26a7a3a990e497fc10df3 Mon Sep 17 00:00:00 2001 From: Ganesh Kandu Date: Tue, 27 Oct 2020 17:42:35 +0530 Subject: [PATCH 1/2] Replaced PHP_EOL to "\n" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit i was getting error ``` An error occurred while parsing JSON configuration file (data/config.json.php): error code #4 ➜ Syntax error Please check your JSON syntax (without PHP comment tags) using a JSON lint tool such as jsonlint.com. ``` after debug i found ```php $data = str_replace(self::getPhpHeaders(), '', $data); $data = str_replace(self::getPhpSuffix(), '', $data); ``` doesn't removing php header and php suffix cause of this issue was PHP_EOL represents the endline character for the current system. if my ```config.json.php``` was encoded with unix ( LF ) and php running on windows windows encoding ( CR LF ) is not same as unix encoding ( LF ) so ```str_replace``` doesn't replace strin then it causes issue. --- application/config/ConfigJson.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/config/ConfigJson.php b/application/config/ConfigJson.php index c0c0dab9..eaa4ee3f 100644 --- a/application/config/ConfigJson.php +++ b/application/config/ConfigJson.php @@ -73,7 +73,7 @@ public function getExtension() */ public static function getPhpHeaders() { - return ''; + return "\n" . '*/ ?>'; } } From e69e3fef7bbdc7299ae01aa0e0258395d2e49818 Mon Sep 17 00:00:00 2001 From: Ganesh Kandu Date: Tue, 27 Oct 2020 18:08:14 +0530 Subject: [PATCH 2/2] Removed PHP_EOL just replace "*/ ?>" and "'; + return '*/ ?>'; } }