Welcome Guest, Not a member yet? Register   Sign In
Parse Error in Production and Not Local Server
#1

Hello. I'm new to the forum but not new to CI. Been a user since CI3. I just downloaded a fresh copy of CI and developed a starter site in WAMP. All was working great; pushed it over to production server and it wont load. The server error log says:

Error Log Excerpt
Code:
[12-Oct-2021 14:45:24 America/Chicago] PHP Parse error:  syntax error, unexpected ':', expecting '{' in /mysite/system/Common.php on line 44


System/Common.php Excerpt
Code:
if (! function_exists('app_timezone')) {
    /**
    * Returns the timezone the application has been set to display
    * dates in. This might be different than the timezone set
    * at the server level, as you often want to stores dates in UTC
    * and convert them on the fly for the user.
    */
    function app_timezone(): string    /**Line 44*/
    {
        $config = config(App::class);

        return $config->appTimezone;
    }
}

Just as the CI user's guide says, I did not modify any sys files.

Anyone run into the same issue?  I researched a bit but never found anything. Any/all help on this would be greatly appreciated. [/code]
Reply
#2

What version of PHP? CI4 require PHP 7.3
http://codeigniter.com/user_guide/intro/...ments.html
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
Reply
#3

(This post was last modified: 10-13-2021, 06:19 AM by jdmdigital.)

Thanks for asking. I forgot to mention the server php version.

Localhost: 7.3.21
production: 7.4

I think i'll retrograde my production server to see if that fixes it. but CI4 says 7.3 or younger.

update: retrograde to 7.3 on production worked. should I report this to the devs so they can look into a 7.4 fix?
Reply
#4

Dev here. That's weird, return types were introduced in PHP 7 so it being at 7.4 doesn't matter.
Reply
#5

I'm running on php 8.0.11 and never seen a problem like that.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

I just switched my localhost server to php7.4.9 and cycled through the site; no issues. I'll upgrade the production site back to 7.4 this weekend and see if the bug remains or was a fluke.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB