CodeIgniter Forums
I have setup new CodeIgniter but i have getting this issue - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: I have setup new CodeIgniter but i have getting this issue (/showthread.php?tid=74380)



I have setup new CodeIgniter but i have getting this issue - Dharmeshghadiya - 09-17-2019

when I have run this command in CLI php spark serve then display this message 

PHP Parse error:  syntax error, unexpected '?' in E:\xampp7\htdocs\project\CodeIgniter4\system\

Common.php on line 924


RE: I have setup new CodeIgniter but i have getting this issue - ciadmin - 09-17-2019

It looks like you have modified Common.php, as there is no "?" on line 924.
Which CI 4 version are you using, and which install method did you use?
You might want to post lines 920-930 of your Common.php


RE: I have setup new CodeIgniter but i have getting this issue - Dharmeshghadiya - 09-17-2019

(09-17-2019, 10:07 AM)ciadmin Wrote: It looks like you have modified Common.php, as there is no "?" on line 924.
Which CI 4 version are you using, and which install method did you use?
You might want to post lines 920-930 of your Common.php

I have not any changed in common.php 

There is Code is


if (!function_exists('slash_item')) {
    //Unlike CI3, this function is placed here because
    //it's not a config, or part of a config.
    /**
    * Fetch a config file item with slash appended (if not empty)
    *
    * @param string $item Config item name
    *
    * @return string|null The configuration item or NULL if
    * the item doesn't exist
    */
    function slash_item(string $item): ?string
    {
        $config = config(App::class);
        $configItem = $config->{$item};

        if (!isset($configItem) || empty(trim($configItem))) {
            return $configItem;
        }

        return rtrim($configItem, '/') . '/';
    }
}


I have bold this string there is an issue is display


RE: I have setup new CodeIgniter but i have getting this issue - kilishan - 09-17-2019

Make sure your PHP version is 7.2 or higher.


RE: I have setup new CodeIgniter but i have getting this issue - ciadmin - 09-17-2019

Something is definitely out of whack: line 924 in the latest, rc.1, is in the middle of the stringify_attributes function, not slash_item. You didn't say which version you are running, but it doesn't look like the latest.

The line you bolded has a nullable return type declared, i.e. slash_item can return either a string or null.
This sounds more like a PHP version compatibility problem ... the git bash shell can have issues with PHP, from what I have seen.
Possible workaround: https://superuser.com/questions/1238410/running-php-works-in-command-prompt-but-not-git-bash