CodeIgniter generally shows, “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, there are other reasons this error could be triggered, such as using poor codes 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 Severity: Warning Message: ini_set(): A session is active. You cannot change the session module's ini settings at this time Filename: Session/Session.php Line Number: 284 Backtrace: File: /home/cPanelusername/public_html/domain.com/application/controllers/Site.php Line: 8 Function: __construct File: /home/cPanelusername/public_html/domain.com/index.php Line: 318 Function: require_once
Here:
- 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, “PHP Error was Encountered”:
Step 1
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’]);
Step 2
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/’;
Step 3
In index.php find for session_start(); and comment it as below
//session_start();
Conclusion
Thus by following the above steps, you can fix the CodeIgnitor error, a “PHP Error was encountered”.