Jump to content

using $this inside a function


dhinge

Recommended Posts

I have an object called "logger" inside of $this, which I'm trying to use inside of a function (not a method).

 

function parseDate($date) {

    $this->logger->debug($this, "date is $date");

    // parse parse parse

}

 

I run it and get "Fatal error:  Using $this when not in object context". If I add: "global $this" I get: Fatal error</b>:  Cannot re-assign $this

 

I have to have "$this" to run the logger, so how do I get the function to recognize $this?

Link to comment
https://forums.phpfreaks.com/topic/179849-using-this-inside-a-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.