获取配置信息时提示使用未定义常量,php版本7.3.15
weeisc opened this issue · comments
weeisc commented
文件内容:
vi foo.ini
name="yaconf" ;string
year=2020 ;number
features[]="fast" ;map
features.1="light"
features.plus="zero-copy"
features.constant=PHP_VERSION ;PHP constants
提示如下:
php -r "var_dump(Yaconf::get("foo"));"
PHP Warning: Use of undefined constant foo - assumed 'foo' (this will throw an Error in a future version of PHP) in Command line code on line 1
Warning: Use of undefined constant foo - assumed 'foo' (this will throw an Error in a future version of PHP) in Command line code on line 1
array(3) {
["name"]=>
string(6) "yaconf"
["year"]=>
string(4) "2020"
["features"]=>
array(4) {
[0]=>
string(4) "fast"
[1]=>
string(5) "light"
["plus"]=>
string(9) "zero-copy"
["constant"]=>
string(6) "7.3.15"
}
}
php -r "var_dump(Yaconf::get("foo.name"));"
PHP Warning: Use of undefined constant foo - assumed 'foo' (this will throw an Error in a future version of PHP) in Command line code on line 1
Warning: Use of undefined constant foo - assumed 'foo' (this will throw an Error in a future version of PHP) in Command line code on line 1
PHP Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in Command line code on line 1
Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in Command line code on line 1
NULL
Xinchen Hui commented
请用:
php -r 'var_dump(Yaconf::get("foo.name"));'
注意“单引号”的变化
weeisc commented
也是脑抽了