Welcome Guest, Not a member yet? Register   Sign In
Is strict_types=1 still necessary?
#1

Hi,

All my code in ci3 had these two lines at the top of the page:

PHP Code:
declare(strict_types=1);
defined('BASEPATH') OR exit('No direct script access allowed'); 

Are they still needed in ci4?

Thanks
Reply
#2

Declaring strict_types was never required in CI3, but it's good to have to help with obscure errors. You can still use it if you want or need to. The defined BASEPATH is no longer used in CI4.
Reply
#3

(This post was last modified: 01-20-2022, 03:59 AM by kenjis.)

declare(strict_types=1); is good practice.
See https://www.php.net/manual/en/language.t...ons.strict

CI4 does not use the constant BASEPATH.
So if you don't remove defined('BASEPATH') OR exit('No direct script access allowed');,
CI4 does not work.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB