调试php.ini语法错误
我有一个带有Ubuntu12.04的虚拟机,运行apache2作为web服务器。我已经安装了PHP 5.3.10,每次运行PHP应用程序时,我的PHP.ini都会抛出以下错误:调试php.ini语法错误,php,ubuntu,apache2,Php,Ubuntu,Apache2,我有一个带有Ubuntu12.04的虚拟机,运行apache2作为web服务器。我已经安装了PHP 5.3.10,每次运行PHP应用程序时,我的PHP.ini都会抛出以下错误: PHP: syntax error, unexpected BOOL_FALSE in /etc/php5/cli/php.ini on line 1020 我希望php.ini中的某些内容没有被正确注释掉,但当我查看它时,我看不出有什么问题: 1007 [Pcre] 1008 ;PCRE library backt
PHP: syntax error, unexpected BOOL_FALSE in /etc/php5/cli/php.ini on line 1020
我希望php.ini中的某些内容没有被正确注释掉,但当我查看它时,我看不出有什么问题:
1007 [Pcre]
1008 ;PCRE library backtracking limit.
1009 ; http://php.net/pcre.backtrack-limit
1010 ;pcre.backtrack_limit=100000
1011
1012 ;PCRE library recursion limit.
1013 ;Please note that if you set this value to a high number you may consume all
1014 ;the available process stack and eventually crash PHP (due to reaching the
1015 ;stack size limit imposed by the Operating System).
1016 ; http://php.net/pcre.recursion-limit
1017 ;pcre.recursion_limit=100000
1018
1019 [Pdo]
1020 ; Whether to pool ODBC connections. Can be one of "strict", "relaxed" or "off"
1021 ; http://php.net/pdo-odbc.connection-pooling
1022 ;pdo_odbc.connection_pooling=strict
1023
1024 ;pdo_odbc.db2_instance_name
1025
1026 [Pdo_mysql]
1027 ; If mysqlnd is used: Number of cache slots for the internal result set cache
1028 ; http://php.net/pdo_mysql.cache_size
1029 pdo_mysql.cache_size = 2000
1030
1031 ; Default socket name for local MySQL connects. If empty, uses the built-in
1032 ; MySQL defaults.
1033 ; http://php.net/pdo_mysql.default-socket
1034 pdo_mysql.default_socket=
这有什么奇怪的吗
所有的应用程序都在运行,我只是厌倦了看到这个错误,而不知道是什么导致了它 简短答复:
不要相信行号,在错误中提到的行之前的行中查找语法错误
长答覆:
我也犯了这个错误,结果我在时区周围漏掉了一个引号
我最初的错误是:
PHP: syntax error, unexpected BOOL_FALSE in /etc/php5/cli/php.ini on line 929
在线876我有:
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Europe/Madrid"
在那之后有很多注释掉的行,下一个未注释的行在938。最初的错误是在第929行出现了一个错误,这使得事情变得很神秘。我假设行号的差异与php.ini文件的解析方式有关,但问题是行号不可信
在我更正了第876行缺少的引号后,出现了错误。简短回答:
不要相信行号,在错误中提到的行之前的行中查找语法错误
长答覆:
我也犯了这个错误,结果我在时区周围漏掉了一个引号
我最初的错误是:
PHP: syntax error, unexpected BOOL_FALSE in /etc/php5/cli/php.ini on line 929
在线876我有:
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Europe/Madrid"
在那之后有很多注释掉的行,下一个未注释的行在938。最初的错误是在第929行出现了一个错误,这使得事情变得很神秘。我假设行号的差异与php.ini文件的解析方式有关,但问题是行号不可信
在我更正了第876行缺少的引号后,出现了错误。此函数解决了问题,并修复了PHP parse_ini_文件生成的一些错误。 另外,xtalk_parse_ini_文件的工作方式与parse_ini_文件类似
function xtalk_parse_ini_file( $filename ){
$arr = array();
$file = fopen( $filename, "r" );
$section = "";
$ident = "";
$value = "";
while ( !feof( $file ) ){
$linha = trim(fgets( $file ));
if (!$linha){
continue;
}
// replace comments
if (substr($linha, 0, 1) == ";"){
continue;
}
if (substr($linha, 0, 1) == "["){
$section = substr($linha, 1, strlen($linha)-2);
continue;
}
$pos = strpos($linha, "=");
if ($pos){
$ident = trim(substr($linha, 0, $pos - 1));
$value = trim(substr($linha, $pos + 1, strlen($linha) - $pos + 1 ));
$pos = strpos($value, ";");
if ( $pos ){
$value = trim(substr($value, 0, $pos - 1 )); // replace comments
}
}
$arr[$section][$ident] = $value;
}
fclose($file);
return $arr;
}
该函数解决了这个问题,并修复了PHP parse_ini_文件生成的一些错误。 另外,xtalk_parse_ini_文件的工作方式与parse_ini_文件类似
function xtalk_parse_ini_file( $filename ){
$arr = array();
$file = fopen( $filename, "r" );
$section = "";
$ident = "";
$value = "";
while ( !feof( $file ) ){
$linha = trim(fgets( $file ));
if (!$linha){
continue;
}
// replace comments
if (substr($linha, 0, 1) == ";"){
continue;
}
if (substr($linha, 0, 1) == "["){
$section = substr($linha, 1, strlen($linha)-2);
continue;
}
$pos = strpos($linha, "=");
if ($pos){
$ident = trim(substr($linha, 0, $pos - 1));
$value = trim(substr($linha, $pos + 1, strlen($linha) - $pos + 1 ));
$pos = strpos($value, ";");
if ( $pos ){
$value = trim(substr($value, 0, $pos - 1 )); // replace comments
}
}
$arr[$section][$ident] = $value;
}
fclose($file);
return $arr;
}
重新启动php?正确的php.ini?(用phpinfo检查ini的路径)看起来您在php.ini文件的某个地方使用保留关键字作为键。由于使用保留关键字,通常会出现意外的BOOL_FALSE-Yes、No、Null、True、FALSE、On、Off、None。如果必须使用这些术语,可以使用反勾号(``)。第1034行**pdo_mysql.default_socket=**它是未分配的,正如我所能看到的那样message@developerCK-“如果为空,则使用内置的MySQL默认值。”它可以为空,没有问题。重新启动php?正确的php.ini?(用phpinfo检查ini的路径)看起来您在php.ini文件的某个地方使用保留关键字作为键。由于使用保留关键字,通常会出现意外的BOOL_FALSE-Yes、No、Null、True、FALSE、On、Off、None。如果必须使用这些术语,可以使用反勾号(``)。第1034行**pdo_mysql.default_socket=**它是未分配的,正如我所能看到的那样message@developerCK-“如果为空,则使用内置的MySQL默认值。”它可以为空,没有问题。您好,欢迎使用SO。请避免只回答代码。编辑您的帖子并简要解释您的解决方案。这将有助于OP和其他人更好地理解你的想法。嗨,欢迎来到SO。请避免只回答代码。编辑您的帖子并简要解释您的解决方案。这将有助于OP和其他人更好地理解你的想法。