gpt4 book ai didi

PHP parse_ini_file 错误

转载 作者:行者123 更新时间:2023-12-05 02:24:35 39 4
gpt4 key购买 nike

我正在使用 parse_ini_file 来读取文件的内容,但并不总是成功。

例如,这个文件工作正常:

[playlist]
numberofentries=3
File1=http://scfire-dtc-aa05.stream.aol.com:80/stream/1010
Title1=(#1 - 168/11500) Absolutely Smooth Jazz - SKY.FM - the world's smoothest jazz 24 hours a day
Length1=-1
File2=http://scfire-ntc-aa06.stream.aol.com:80/stream/1010
Title2=(#2 - 171/11500) Absolutely Smooth Jazz - SKY.FM - the world's smoothest jazz 24 hours a day
Length1=-1
File3=http://scfire-mtc-aa04.stream.aol.com:80/stream/1010
Title3=(#3 - 175/11500) Absolutely Smooth Jazz - SKY.FM - the world's smoothest jazz 24 hours a day
Length1=-1
Version=2

然而,当我使用 parse_ini_file 读取以下文件时,我收到一条错误消息,指出它无法解析该文件:

[playlist]
numberofentries=3
File1=http://87.230.82.17:80
Title1=(#1 - 365/1400) DEFJAY.DE - 100% R&B! (GERMANY)
Length1=-1
File2=http://87.230.56.25:80
Title2=(#2 - 370/1400) DEFJAY.DE - 100% R&B! (GERMANY)
Length1=-1
File3=http://87.230.56.32:80
Title3=(#3 - 375/1400) DEFJAY.DE - 100% R&B! (GERMANY)
Length1=-1
Version=2

这是我读取文件的代码:

$file = "test.pls";
$ini_array = parse_ini_file($file, true);
$audiostream = $ini_array['playlist']['File1'];
echo "stream is: ".$audiostream;

我看不出文件之间有什么区别。有人知道出了什么问题吗?

谢谢

最佳答案

首先您需要附上您的非字母数字字符

来自手册:

If a value in the ini file contains any non-alphanumeric characters it needs to be enclosed in double-quotes (").

PHP.net - parse_ini_file

所以:

[playlist]
numberofentries=3
File1="http://87.230.82.17:80"
Title1="(#1 - 365/1400) DEFJAY.DE - 100% R&B! (GERMANY)"
Length1=-1
File2="http://87.230.56.25:80"
Title2="(#2 - 370/1400) DEFJAY.DE - 100% R&B! (GERMANY)"
Length1=-1
File3="http://87.230.56.32:80"
Title3="(#3 - 375/1400) DEFJAY.DE - 100% R&B! (GERMANY)"
Length1=-1
Version=2

另请注意,这里有保留字:

There are reserved words which must not be used as keys for ini files. These include: null, yes, no, true, false, on, off, none. Values null, no and false results in "", yes and true results in "1". Characters ?{}|&~![()^" must not be used anywhere in the key and have a special meaning in the value

关于PHP parse_ini_file 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11031661/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com