尝试设置 CodeIgniter 4.2 时出现以下错误
PHP Parse error: syntax error, unexpected '_592_000' (T_STRING), expecting ',' or ')' in C:\xampp\htdocs\Test1\app\Config\Constants.php on line 41
我没有对 Constants.php
进行任何更改。
最佳答案
错误:
PHP Parse error: syntax error, unexpected '_592_000' (T_STRING), expecting ',' or ')' in C:\xampp\htdocs\Test1\app\Config\Constants.php on line 41
说明:
您收到上述错误是因为文件 app\Config\Constants.php
使用数字文字分隔符。
Excerpt from app\Config\Constants.php
:
defined('MONTH') || define('MONTH', 2_592_000);
defined('YEAR') || define('YEAR', 31_536_000);
defined('DECADE') || define('DECADE', 315_360_000);
Numeric literal separators were once proposed as a feature using RFCs于2019年5月15日。
The human eye is not optimized for quickly parsing long sequences of digits. Thus, a lack of visual separators makes it take longer to read and debug code, and can lead to unintended mistakes.
numeric literal separator feature was later implemented在 PHP 7.4 中。
Numeric literals can contain underscores between digits.
基于 CodeIgniter v4.2.0
's composer.json
file 的内容,很明显,您需要在计算机上安装 PHP 7.4
及更高版本才能顺利运行。
"require": { "php": "^7.4 || ^8.0", }
解决方案:
确保您运行的是 PHP v7.4
及更高版本。
附录:
如果您不知道如何检查当前的 PHP 版本,请打开终端或命令提示符并运行命令 php --version
:
$ php --version
PHP 8.1.3 (cli) (built: Feb 16 2022 08:20:53) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.3, Copyright (c) Zend Technologies
关于codeigniter - 设置 CodeIgniter 4.2 时如何解决错误 "unexpected ' _592_00 0'"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72644818/