我有一个使用config.inc.php文件的文件管理器。我想知道如何在此文件中使用预定义的变量,但我不知道如何操作。
我想知道这种语法是如何调用的,以及如何使用变量。
;<?php/* do not delete this line!
[FTP]
; FTP access; leave empty to use local file system instead
ftpHost = "127.0.0.1" ; FTP server name
ftpUser = "test" ; FTP user name
ftpPassword = "test" ; FTP password
ftpPort = 21 ; FTP port number (default is 21)
ftpPassiveMode = yes ; use passive mode
ftpSSL = no ; use FTPS
; do not delete this line! */?>
它看起来像一个受PHP标签保护并使用parse_ini_file
读取的INI
文件
在以下位置添加:
ftpSSL = no ; use FTPS
这:
customVar = "var" ; custom variable
您可以添加其他变量,但我认为您不能从外部分配一个变量。
看看parse_ini_file函数:http://php.net/manual/en/function.parse-ini-file.php
这会将输入文件转换为可以轻松查询的数组。
例如:
$ini = parse_ini_file("config.inc.php");
print_r($ini);