【问题标题】:PHP parse_ini_file with slashes in WINDOWS PHP 5.3.0WINDOWS PHP 5.3.0 中带有斜线的 PHP parse_ini_file
【发布时间】:2012-03-14 10:22:44
【问题描述】:

我正在使用 wiki 软件:dokuwiki,安装模板后:http://www.dokuwiki.org/template:monobook

我在 Windows 7 64 位上使用 WAMP 进行本地测试时遇到此错误: 阿帕奇:2.2.11
PHP:5.3.0

更新 我已将我的 PHP 版本升级到 5.3.1,这已经修复了错误。

警告:解析错误 C:\wamp\www\wiki\lib\exe/../../lib/tpl/monobook/style.ini 在第 30 行 在 C:\wamp\www\wiki\lib\exe\css.php54
警告 中:提供的参数无效foreach() 在 C:\wamp\www\wiki\lib\exe\css.php55 行

style.ini

; INI to handle loading of the CSS files of the "monobook" template for DokuWiki
;
;
; LICENSE: This file is open source software (OSS) and may be copied under
;          certain conditions. See COPYING file for details or try to contact
;          the author(s) of this file in doubt.
;
; @license GPLv2 (http://www.gnu.org/licenses/gpl2.html)
; @author Andreas Haerter <development@andreas-haerter.com>
; @link http://andreas-haerter.com/projects/dokuwiki-template-monobook
; @link http://www.dokuwiki.org/template:monobook
; @link http://www.dokuwiki.org/devel:css#styleini



; Please see http://www.php.net/manual/en/function.parse-ini-file.php
; for limitations of the ini format used here

; Define the stylesheets your template uses here. The second value
; defines for which output media the style should be loaded. Currently
; print, screen and rtl are supported. rtl styles are loaded additionally
; to screen styles if a right-to-left language is selected (eg. hebrew)
[stylesheets]

; screen
; note to myself: don't forget to respect the workaround within "bug49642.php"
;                 when adding new screen styles.
; load the DokuWiki styles. See <http://j.mp/eq8zSo> why I am doing this.
[line:30] static/3rd/dokuwiki/_imgdetail.css        = screen
static/3rd/dokuwiki/_media_popup.css      = screen
static/3rd/dokuwiki/_media_fullscreen.css = screen
static/3rd/dokuwiki/_fileuploader.css     = screen
static/3rd/dokuwiki/_tabs.css             = screen
static/3rd/dokuwiki/_links.css            = screen
static/3rd/dokuwiki/_toc.css              = screen
static/3rd/dokuwiki/_footnotes.css        = screen
static/3rd/dokuwiki/_search.css           = screen
static/3rd/dokuwiki/_recent.css           = screen
static/3rd/dokuwiki/_diff.css             = screen
static/3rd/dokuwiki/_edit.css             = screen
static/3rd/dokuwiki/_modal.css            = screen
static/3rd/dokuwiki/_forms.css            = screen
static/3rd/dokuwiki/_admin.css            = screen

; load the most important MediaWiki monobook styles
static/3rd/monobook/main.css = screen

; load the specific "monobook for dokuwiki" styles
static/css/screen.css = screen
user/screen.css       = screen

这是加载ini文件的css.php中的PHP代码:

// load template styles
$tplstyles = array();
if(@file_exists($tplinc.'style.ini')){
    $ini = parse_ini_file($tplinc.'style.ini',true);
    foreach($ini['stylesheets'] as $file => $mode){
        $tplstyles[$mode][$tplinc.$file] = $tpldir;
    }
}

【问题讨论】:

  • 使用 PHP/5.2.17-win32 对我来说上面的文件解析 OK(一旦 [line:30] 已从我的编辑器中的实际第 29 行中删除)。斜杠不是 ini 文件中的 AFAIK 特殊字符,在键中应该是合法的。这是一个简单的 ISO-8859-1 文件吗?没有 UTF 让你乱七八糟?
  • PHP 5.3 正在解析这个文件,没有问题(在 Mac 上)
  • 是的,两者都正确,我刚刚在 Linux 服务器上进行了测试,它工作正常。这一定是 PHP 版本的问题,因为一旦我升级到 5.3.1,错误就消失了。

标签: php ini dokuwiki


【解决方案1】:

这确实是 PHP 5.3.0 中的一个已知错误。见https://bugs.php.net/bug.php?id=49692

【讨论】:

    猜你喜欢
    • 2013-05-10
    • 2013-01-22
    • 2011-08-09
    • 2012-06-17
    • 2015-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-21
    相关资源
    最近更新 更多