CodeIgniter generally shows, “A PHP Error was encountered,” when there are issues in the codes that have been used in the website.
In this article, we will understand the reasons why this CodeIgniter error occurs and the steps to fix it.
Why Does CodeIgniter, “A PHP Error was Encountered” Appears?
Besides, the issues in the website code, there are other reasons this error could be triggered, such as poor code structures or any type of issue with the database server.
When this error encounters, you see an error message in the below format:
A PHP Error was encountered
Message: ini_set(): A session is active. You cannot change the session module's ini settings at this time
Line Number: 284
- Severity: Specifies whether the issue is major or minor. It can be in the form or Notice or Warning.
- Message: Shows information about the nature of the error.
- File Name: The file name which is causing the issue.
- Line Number: The line for checking such error.
Steps to Fix the CodeIgniter Error, “A PHP Error was Encountered”
Here are the steps to fix the CodeIgniter error, “A PHP Error was encountered”:
Open file application/config/config.php and replace http with https like below.
$path = “https://”.$_SERVER[‘HTTP_HOST’].str_replace(basename($_SERVER[‘SCRIPT_NAME’]),””,$_SERVER[‘SCRIPT_NAME’]);
In application/config/config.php ; sess_save_path should be set as below. Create ci_sessions directory in application folder in domain’s document root and update ownership
$config[‘sess_save_path’] = APPPATH . ‘ci_sessions/’;
In index.php find for session_start(); and comment it as below
Thus by following the above steps, you can fix the CodeIgnitor error, “A PHP Error was encountered”.