Knowledge Base
MilesWeb / How-Tos

How to Fix CodeIgniter Error, “A PHP Error was Encountered”?

Approx. read time : 2 min

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, 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:

PHP Error Encountered

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, “A 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”.

Nehal Khatri
Nehal is an ardent content writer. She's passionate about crafting content that's simple but adds value. Her insatiable interest in writing has allowed her to explore her skills. She is adept and can write for different types of content formats.