Home > Blockchain >  How do you resolve the error "unexpected '_592_000'" while setting up CodeIgnite
How do you resolve the error "unexpected '_592_000'" while setting up CodeIgnite

Time:06-25

I got the below error when trying to set up 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

I didn't change anything on Constants.php.

CodePudding user response:

You need to remove the '_'

defined('MONTH')  || define('MONTH', 2592000);
defined('YEAR')   || define('YEAR', 31536000);
defined('DECADE') || define('DECADE', 315360000);

CodePudding user response:

Error:

PHP Parse error: syntax error, unexpected '_592_000' (T_STRING), expecting ',' or ')' in C:\xampp\htdocs\Test1\app\Config\Constants.php on line 41

Explanation:

You're receiving the error above because the file app\Config\Constants.php uses Numeric literal separators.

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 on 2019-05-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.

The numeric literal separator feature was later implemented in PHP 7.4.

Numeric literals can contain underscores between digits.

Based on the contents of CodeIgniter v4.2.0's composer.json file, it's clear that you're required to have installed PHP 7.4 and above on your computer for it to run smoothly.

    "require": {
        "php": "^7.4 || ^8.0",
    }

Solution:

Make sure you're running PHP v7.4 and above.


Addendum:

If you don't know how to check your current PHP version, open your terminal or command prompt and run the command 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

  • Related