Skip to content
Advertisement

Using $this when not in object context in PHP

I don’t know why i’m getting this error: Fatal error: Uncaught Error: Using $this when not in object context in C:xampphtdocsappindex.php:19 Stack trace: #0 {main}

This is my index.php and where the error points out:

JavaScript

I’m kinda lost solving this for half a day, so i’m reaching out here

Advertisement

Answer

You are not inside instance of class to use $this. Try this, it will work

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement