2016-12-14 47 views
1

好由於某種原因,我使用parse_ini_file(),我不斷收到錯誤消息,它說parse_ini_file()保持outputing一個錯誤,當我用它

警告:語法錯誤,在app/config中意外END_OF_LINE。 INI第10行在C:\ XAMPP \ htdocs中\的index.php第2行

我的config.ini包含

[meta] 
keywords=%nodata% 
description=%nodata% 
author=Nicholas English 
[email protected] 
robots=all 
dnsprefetch=off 
cachecontrol=no-cache 
fragment=! 

我的index.php包含

<?php 
$config = parse_ini_file("app/config.ini", true); 
$meta = $config['meta']; 
?> 

我有谷歌搜索,沒有運氣,我試圖做到這一點我的自我,但它仍然不會工作。

任何幫助將是驚人的,提前謝謝你。

+0

您確定在文件末尾沒有空行嗎? –

+0

空行或不行它仍然顯示該錯誤。 –

回答

1

使用​​選項:

$config = parse_ini_file("app/config.ini", true, INI_SCANNER_RAW); 

在默認模式(INI_SCANNER_NORMAL)PHP禁止感嘆號引號值:

如果在ini文件中的值包含它所需要的任何非字母數字字符(「)

因此,無論是使用原始掃描儀還是引用值es帶有非字母數字值,例如:

fragment="!" 
相關問題