Jump to content

Using $this


frozenmafia

Recommended Posts

yeah it is in a classes.php where everything works off. It works everywhere else in the code  :wtf:

 

That really doesn't answer the question. Just because the file is named classes.php doesn't mean anything. Is that line in a properly declared CLASS.

 

Example:

<?php
class Time
{
  var $sTime;

  function GenerateCurrentTime(){
    $this->sTime = gmdate("d-m-Y H:i:s");
    return $this->sTime;
  }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/204306-using-this/#findComment-1070033
Share on other sites

As suspected, your problem is a scope problem. You're trying to use $this inside of the gradient function, it is not defined there. Read about variable scopes here.

 

Why are you even using OOP in the first place? You're not using it in any way shape or form that would give you an advantage. It's a horrible implementation, all you're doing is packing everything inside the constructor of the object.

Link to comment
https://forums.phpfreaks.com/topic/204306-using-this/#findComment-1070103
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.