[vox-tech] PHP: My object's method vanishes

Richard S. Crawford rscrawford at mossroot.com
Fri Dec 9 15:15:42 PST 2005


This is for a wishlist program that I've been developing for my family.

I have a class called Person which looks something like this:

========================================

class Person {

  var $personFullName;
  var $recipientList;

  function Person ($personKey) {
    global $CFG;
    $personQuery = "select * from ".$CFG->db['prefix']."person where
personKey = $personKey";
    if (!$person = dbquery($personQuery)) {
      return false;
    }
    $this = $person[0];
    $this->personFullName = $this->personFirstName . " " .
$this->personLastName;

  }

  function bob() {
  }

}

========================================

I can call the constructor object just fine with:

========================================

$USER = new Person($userKey);

========================================

However, when I try this:

========================================

USER->bob()

========================================

I get this error:

========================================

Fatal error: Call to undefined function: bob()

========================================

...which I don't understand at all, since I have another Class which is
called in pretty much the same way, and I have no problem calling any
methods for that other class.  I can't find any significant structural
differences between the two classes.

I tried introducing a deliberate error into the definition for the
function bob(), and sure enough the program died when the page with the
malformed function was loaded.

I'm sure I'm missing something very obvious which will embarrass me
completely once it's pointed out to me, but at the moment I have no idea
what it might be.

-- 
Richard S. Crawford
http://www.mossroot.com
"That which does not kill me makes me stranger."
--Llewellyn


More information about the vox-tech mailing list