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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.