我正在使用parse_ini_file來讀取文件的內容,但它並不總是成功。PHP 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;
我看不到文件之間有太大的區別。任何人都知道發生了什麼問題?
感謝
我只是猜測這裏有特殊的含義,但我懷疑你實際上得到正確的錯誤信息,以說明問題出在什麼地方,出錯的地方,你從你的問題中任意決定使用哪一個。 – lanzz