https://github.com/shukean/php-toml
A php extension for parse toml file
https://github.com/shukean/php-toml
Last synced: about 1 year ago
JSON representation
A php extension for parse toml file
- Host: GitHub
- URL: https://github.com/shukean/php-toml
- Owner: shukean
- License: mit
- Created: 2016-06-20T05:53:19.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-01-10T02:28:33.000Z (over 9 years ago)
- Last Synced: 2024-11-13T06:32:50.744Z (over 1 year ago)
- Language: C
- Size: 35.2 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-php-extensions - php-toml - 解析 toml 文件 (数据转换)
README
# php-toml
A php7 extension for parse toml file
## Toml v0.4.0
https://github.com/toml-lang/toml
## Methods
`array toml_parse_file(string toml_file_name) `
`array toml_parse_string(string toml_contents) `
### Parameters
`toml_file_name`: Name of the file read.
`toml_contents`: A toml struct string.
### Return Values
The function returns array or **False** on failure.
### Errors/Exceptions
An E_ERROR level error is generated if toml contents parse fail, file cannot be found.
An E_NOTICE level error is generated if toml contents is empty.
## PHP.ini
toml.cache_enable = 1/0
If enable cache, toml\_parse_file function will cahce the success result.
If file updated, the file cache will auto reload on the next call.
## Toml Syntax Supported
### Comment
1. a full-line comment : **yes**
2. a comment at the end of a line : **yes**
### Bool
1. true / false : **yes**
*bool value must be lowercase letter*
### Key/Value Pair
1. bare keys : **yes**
2. quoted keys : **yes**
3. empty keys: **yes**
*key not defind or empty, the key will replace to index num*
### Integer
1. normal : **yes**
2. positive or negative : **yes**
3. large : **yes**
*the value will be convert to php long*
### Float
1. normal : **yes**
2. positive or negative : **yes**
3. large : **yes**
4. exponent : **yes**
*the value will be convert to php double*
### Datetime
**Not support**
### String
#### Basic strings
**yes**
*value will be called php function __stripcslashes__*
#### Multi-line basic strings
**yes**
extraneous whitespace : **yes**
#### Literal strings
**yes**
#### Multi-line literal strings
**yes**
### Array
**yes**
multiline : **yes**
data types fixed : **yes** (^_^ php is best)
### Table
1. normal : **yes**
2. qoute key : **no** (result is not you wanted)
3. dots : **yes**
### Inline Table
**Not supported**
### Array of Tables
**yes**