Using $this when not in object context--i am using the latest version of php and mysql
<p>This is user.php:
    

<pre><code>    include("databse.php");//retrieving successfully first name and lastname from databse file into user.php
    class user
    {
      public $first_name;
      public $last_name;
      public static function full_name()
      {
          if(isset($this-&gt;first_name) &amp;&amp; isset($this-&gt;last_name))
          {
            return $this-&gt;first_name . " " . $this-&gt;last_name;

          }
          else
           {
                return "";
           }
       }
    }
</code></pre>

<p>Other php file, index.php:</p>

<pre><code>   include(databse.php);
   include(user.php);
    $record = user::find_by_id(1);
    $object = new user();
    $object-&gt;id = $record['id'];
    $object-&gt;username = $record['username'];
    $object-&gt;password = $record['password'];
    $object-&gt;first_name = $record['first_name'];
    $object-&gt;last_name = $record['last_name'];
    // echo   $object-&gt;full_name();
    echo $object-&gt;id;// successfully print the id
    echo $object-&gt;username;//success fully print the username
    echo-&gt;$object-&gt;full_name();//**ERROR:Using $this when not in object context**

?&gt;
</code></pre>
