diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 7cc14060aac..d16a2b90243 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2384,3 +2384,75 @@ function price2fec($amount) return $output; } + +/** + * Check the syntax of some PHP code. + * @param string $code PHP code to check. + * @return boolean|array If false, then check was successful, otherwise an array(message,line) of errors is returned. + */ +function phpSyntaxError($code) +{ + if (!defined("CR")) define("CR","\r"); + if (!defined("LF")) define("LF","\n") ; + if (!defined("CRLF")) define("CRLF","\r\n") ; + + $braces=0; + $inString=0; + foreach (token_get_all('