CodeIgniter Forums
CI 3.1.11, PHP 7.4, url_helper Critical Error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: CI 3.1.11, PHP 7.4, url_helper Critical Error (/thread-78148.html)



CI 3.1.11, PHP 7.4, url_helper Critical Error - JustBoo - 12-05-2020

Hello. I've been running CI 3.0.6 with PHP 5.6 and 7.2 for years with no problems.



I had to upgrade my PHP version to 7.4 due to my ISP. The site now has the error below:




Message:  Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)`


Filename: helpers/url_helper.php

Line Number: 162



I cannot upgrade to CI 4.x at this time. So I upgraded to 3.1.11.



The offending code is:


PHP Code:
$site_url is_array($uri)
 ? 
site_url($uri)
: (
preg_match('#^(\w+:)?//#i'$uri) ? $uri site_url($uri)); 



Since I don't get a valid url everything is messed up. (No CSS, etc.)



Frankly I don't use PHP enough to know how to convert the is_array() to make use of the parens that PHP 7.4 now wants. Searching came up dry for me.



Any help would be deeply appreciated.  Thank you.


RE: CI 3.1.11, PHP 7.4, url_helper Critical Error - php_rocs - 12-05-2020

@JustBoo,

Any reason why you didn't upgrade your CI version from 3.0.6 to 3.1.11?


RE: CI 3.1.11, PHP 7.4, url_helper Critical Error - php_rocs - 12-06-2020

@JustBoo,

Have you taken the problem code and restructured it to see if you can get a better consistent and correct answer? Have you at least tried to see where at in the problem code the error is happening?


RE: CI 3.1.11, PHP 7.4, url_helper Critical Error - InsiteFX - 12-06-2020

Did you try the CodeIgniter Developer version from GitHub?

CodeIgniter 3.2 Developer Version