Migrating from PHP 5.4 to PHP 5.6 (CodeIgniter code)

1.1k Views Asked by At

Currently, I'm working with php 5.4, and would like to move to 5.6 and also PHP 7. I'm checking the code hosted on my server and realized that there is CodeIgniter code that might outdated.

@ini_get("safe_mode")

Because from what I have searched, safe_mode is no longer supported and deprecated.

I'm not sure about that CodeIgniter code. So wish to ask everyone to confirm whether it's outdated or not. If yes, what is the solution for this?

Example (part of the code):

/*
 * ------------------------------------------------------
 *  Set a liberal script execution time limit
 * ------------------------------------------------------
 */
 if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
 {
    @set_time_limit(300);
 }
2

There are 2 best solutions below

1
On

From the PHP point of view, @ini_get is a function to get the configuration option.. if it does not find the configuration name, it return FALSE as documented here

So, when you're updating to PHP 5.6 or PHP 7, yes it is outdated, but it won't cause error. It's just CodeIgniter will handle things differently.

1
On

If you're using a recent version of CodeIgniter (3.1.x is current), then there should be no problems. The code you've shared there does look a bit ... legacy, this is likely to be an older version. I suggest you check the project documentation and check whether you can upgrade from your version to the newest which should then work with more recent versions of PHP.