diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php
index 1f5a5b52f03b..29c695657f51 100644
--- a/system/Debug/Exceptions.php
+++ b/system/Debug/Exceptions.php
@@ -543,7 +543,7 @@ public static function highlightFile(string $file, int $lineNumber, int $lines =
$source = str_replace(["\r\n", "\r"], "\n", $source);
$source = explode("\n", highlight_string($source, true));
- $source = str_replace('
', "\n", $source[1]);
+ $source = str_replace('
', "\n", PHP_VERSION_ID >= 80300 ? implode('
', $source) : $source[1]);
$source = explode("\n", str_replace("\r\n", "\n", $source));
// Get just the part to show