Fatal error: Using $this when not in object context in CodeIgniter

The error you’re encountering, Using $this when not in object context, typically occurs when trying to use $this outside of an object context in PHP. In CodeIgniter’s view files, $this refers to the CodeIgniter instance, but sometimes it’s not directly accessible due to the view being a separate context.

To resolve this issue, you can pass data from your controller to the view and then use that data within the view.

Here’s an example of how you might modify your code:

In your controller:

The error you’re encountering, Using $this when not in object context, typically occurs when trying to use $this outside of an object context in PHP. In CodeIgniter’s view files, $this refers to the CodeIgniter instance, but sometimes it’s not directly accessible due to the view being a separate context. To resolve this issue, you can…

Leave a Reply

Your email address will not be published. Required fields are marked *