PHPIni (.ini)
PHPIni (.ini)
背景
-
- 配置文件格式.
- 将键与值相关联.
- 收集元素.
- 可用数组或地图等形式表示的 PHP 表达式.
- 为 PHP 应用服务器配置格式.
- 纯文本格式.
Import 与 Export
- Import["file","PHPIni"] 以 Association 形式返回一个文件表示.
- Import["file",{"Ini",elem}] 返回一个文件的特定数据表示.
- Export["file.ini",expr] 将 expr 作为 Ini 文件导出.
- 请到以下参考页面了解完整的基本信息:
-
Import, Export 从文件导入或导出到文件 CloudImport, CloudExport 从云对象导入或导出到云对象 ImportString, ExportString 从字符串导入或导出到字符串 ImportByteArray, ExportByteArray 从字节数组导入或导出到字节数组
参数
- Import 通用参数:
-
"Elements" 该文件可用的参数和选项列表 "Summary" 文件摘要 "Rules" 所有可用参数的规则列表 - 表示数据的参数:
-
"Data" 以关联表示的数据 "DataRules" 以规则列表表示的数据 "CommentedData" 以规则表示分段列表,字符串表示注释,关联表示值的数据 - "PHPIni" 格式导出一个关联或列表的参数.
- "PHPIni" 将一个关联作为分段列表处理. 分段名称由键指定; 作为关联的分段参数由值指定. 表达式转换为其输入格式字符串子表示..
- Wolfram 语言中的列表在 PHPIni 中作为 PHP 数组.
- Wolfram 语言中的关联在 PHPIni 中作为 PHP 映射.
- PHP 符号 "On"、"True" 和 "Yes" 导入为 True. PHP 符号 "Off"、"False" 和 "No" 导入为 False.
- "PHPIni" 接受混合有规则和字符串的列表. 规则以分段导出; 字符串以注释行导出.
- 注释行以 ";" 开始.
- 在第一分段前声明的参数与键 None 相关联.
- "CommentedData" 保留内联注释; 其他数据表示则对其进行删除.
范例
基本范例 (9)
ExportString[<|"PHP" -> <|"max_execution_time" -> 30, "max_input_time" -> 60, "memory_limit" -> "128M"|>|>, "PHPIni"]file = CreateFile[];WriteString[
file, "
[PHP]
engine = On
"];Import[file, "PHPIni"]file = CreateFile[];WriteString[file, "
[PHP]
; ...
[PDO]
pdo_mysql.default_socket = /path/to/mysql.sock
[PostgresSQL]
; Allow or prevent persistent links.
pgsql.allow_persistent = On ; On | Off
"];仅导入数据,作为一个 Association:
Import[file, "PHPIni"]Import[file, {"PHPIni", "CommentedData"}]ImportString["global_key = global_value ", "PHPIni"]ExportString[<|"MyApp" -> <|"SpecialDays" -> {"Monday", "Tuesday", "Friday"}|>|>, "PHPIni"]ExportString[<|"MyApp" -> <|"db_config" -> <|"User" -> "root", "host" -> "localhost", "port" -> "5678"|>|>|>, "PHPIni"]ImportString[" [section]", "PHPIni"]ImportString[" ; comments", "PHPIni"]TakeDrop[{1, 2, 3, 4}, 2]ExportString[<|"GeoData" -> <|"default_position" -> GeoPosition[Entity["City", {"Paris", "IleDeFrance", "France"}]]|>|>, "PHPIni"]ExportString[{None -> {"", " This file is a PHPIni configuration file.", ""}, "section1" -> {"key1" -> <|"Value" -> "element1 ", "Comment" -> " this is the first element"|>}}, "PHPIni"]历史
2017年引入 (11.1)