title: Serialize object from within
body: <p>I have the class <code>testClass</code> which has the method <code>save</code>. This method saves object to a database. But it needs to serialize object before saving. How can I serialize object from within the class to do that?</p>
  
  <pre><code>class testClass {
      private $prop = 777;
      public function save() {
          $serializedObject = serialize(self);
          DB::insert('objects', array('id', 'object'))
                  -&gt;values(array(1, $serializedObject))
                  -&gt;execute();
      }
  }
  </code></pre>
  
  <p>serialize(self) obviously doesn't work.</p>