PHP Fatal error: Call to a member function ... on a non-object : is case-sensitivity

12,762

Of what I can see:

error_log(gettype($userform));
error_log(method_exists($userform, "convert")); //$userform

$result = $userForm->convert($arrData); //$userForm

The convert method exists for $userform, but not $userForm, which is what you're calling the method on. PHP variable names are case sensitive.

Share:
12,762
James Newton
Author by

James Newton

merge keep

Updated on June 05, 2022

Comments

  • James Newton
    James Newton almost 2 years

    PHP 5.2 reports a "PHP Fatal error: Call to a member function convert() on a non-object" although I specifically check that the object exists and that it contains the required method.

    Here is the PHP:

    error_log(gettype($userform));
    error_log(method_exists($userform, "convert"));
    
    $result = $userForm->convert($arrData);
    

    And here are the appropriate extracts from the error log:

    [...] object
    [...] 1
    [...] PHP Fatal error:  Call to a member function convert() on a non-object
          in /file/name.php on line 140
    

    And here is the method itself:

      public function convert(&$arrData) {
        // Bare-bones code
        return true;
      }
    

    What am I overlooking?