3

I just can't figure out why this error is even showing up:

Notice: Undefined variable: authTime in /.../classname.class.php on line 33

class ClassName {

private $authTime = null;


const API_URL       = '...';
const CLIENT_ID     = '...';
const CLIENT_SECRET = '...';

private static $TOKEN     = NULL;


public function __construct() {
$this->_authTime = $authTime; // <----- Line 33
if(!self::$TOKEN OR $this->AuthTime('GET') > 3600 OR !$this->_authTime) {
  self::authorise();
}
}

public function getAuthTime() {
    return $this->_authTime; // Returns NULL
}
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Dwayne Walsh
  • 57
  • 1
  • 8
  • Where is it defined? It is use right after the declaration of the constructor? but never declared. And why the underscore before the property? `_authTime` – mega6382 Oct 20 '17 at 20:31
  • https://stackoverflow.com/review/suggested-edits/17688430 why is that edit adding the rant BACK in?? – Funk Forty Niner Oct 20 '17 at 20:32

1 Answers1

5

I see $authTime is not defined within the constructor. I think you want to do:

$this->_authTime = $this->authTime;
Kamrul Khan
  • 3,260
  • 4
  • 32
  • 59
  • Ok... :o That got rid of the error, but when I try to specify the value of that variable `$this->authTime = time();` I get the same error. **Edit:** My bad, i was calling `$this->` in a static function. Thanks for the help. My hero! :D – Dwayne Walsh Oct 20 '17 at 20:42
  • You are welcome. Im glad I could help :) – Kamrul Khan Oct 20 '17 at 20:48