- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 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 (").
所以:
[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/
我正在使用 parse_ini_file 来读取文件的内容,但并不总是成功。 例如,这个文件工作正常: [playlist] numberofentries=3 File1=http://scfire
我在加载 parse_ini_file 时遇到问题,目前我已经在包含路径中注册了一个路径,但是 parse_ini_file 出现了意外行为(未加载) (小说明:使用phpunit测试,不知道是否影响
我有这个代码: $test = parse_ini_file("../data/test.ini"); test.ini 位于后一个目录,然后转到数据文件夹。但我遇到的问题是 parse_ini_fi
我有一个如下所示的 config.ini 文件: [database] username = user1 password = pass1 dbname = db1 我想用 PHP 解析它,但我没有运
如果我调用 php 的 parse_ini_file("foo.ini"),它会在什么路径中查找 foo.ini?包含路径?该函数的文档没有提及它。 最佳答案 parse_ini_file 的文件名参
我使用 php 命令 parse_ini_file 加载应用程序的配置。查看 php documentation有一个例子,我们在这里看起来,通过使用不带引号的那些 ",数值被排除在外。所以我使用了这
我知道有些人将设置存储在 .ini 文件中,并在 PHP 中使用 parse_ini_file() 获取值。没有运行测试,我对性能很好奇。 如果设置在 ini 文件中,您是否知道操作码缓存是否可以缓存
我遇到了一个奇怪的问题,很奇怪,因为在 Google 上什么也没有出现。我正在尝试解析一个充满 HTTP 状态代码的 ini 文件 StatusCodes.ini。我已经在三种不同的环境中进行了测试,
我想使用像 [parse_ini_file][1] 这样的东西。 例如,我有一个 boot.ini 文件,我将加载该文件以进行进一步的处理: ;database connection sett
parse_ini_file() 有什么替代方案吗?真的有那么危险吗?是禁用它的充分理由,还是我可以以某种方式说服管理员它是安全的? parse_ini_file() has been disable
我有一个包含我的数据库详细信息的 settings.ini.php 文件。 ; [SQL] host = localhost user = root password =Gohead123$ dbna
下面的函数获取“test-backup.ini”文件,解析它并通过 update_option() 方法将值输入到数据库中。 但是,当 ini 文件的值包含特殊字符(如感叹号 (!) 和等号 (=))
PHP 5.3 添加了 $scanner_mode parse_ini_file() 的参数.它是什么? 该文档不是很有用: scanner_mode Can either be INI_SCANNE
我创建了一个带有数据库凭据的 config.ini 文件,并像这样在我的 dbconnect.php 页面中解析该文件 - $config = parse_ini_file('../somefolde
我想在配置文件中保留某个字符串,以便由 PHP 解析 parse_ini_file()功能。但是,此字符串包含一些需要以某种方式编码的特殊字符(代码如 0x2C 或 0x3D)。有什么办法可以在这样的
是否可以使用设置文件创建数组? 在 index.php 文件中,它读取 .ini 文件: // Parse config file $settings = parse_ini_file("settin
我正在尝试创建一个安全的 mysql 连接,并且我创建了一个函数来创建连接和包含登录凭据的 db.ini 文件。 db.ini: [database] user = username pass = p
我有一个 folder.ini 包含: [Labels] ; Ordnername name=testverzeichnis ; Ordnerbeschreibung description=verz
这里是新语言,PHP 对我来说是一种新语言。我正在尝试开发一个网络应用程序。为了保证安全,我试图将我的数据库登录凭据保存在一个简单的 ini 文件(称为 db.ini)中。 1) 我的系统运行的是 U
我有这个文件: [playlist] numberofentries=4 File1=http://108.61.73.119:8128 Title1=(#1 - 266/1000) 181.FM -
我是一名优秀的程序员,十分优秀!