"Call to undefined method X::y()" in PHP — What It Means and How to Fix It
What the PHP error "Call to undefined method X::y()" means and how to fix it.
Published November 1, 2026
You called a method that the object's class does not define. It may be misspelt, defined on a different class or removed.
What it means and why it happens
Typical causes: wrong object type, a typo, calling an instance method statically or using a parent class without the method.
Read the full message: it names the file and line where the problem was detected, which is the best place to start.
What you see
run the code
Fatal error: Uncaught Error: Call to undefined method User::getFullName()
Practical examples
Code that triggers it
<?php
class User { public function name() { return 'Ada'; } }
(new User)->getName(); // no such methodThe fix
<?php
class User { public function name() { return 'Ada'; } }
(new User)->name();Inspect the object
get_class($obj);
method_exists($obj, 'name');
get_class_methods($obj);Common mistakes
- Calling methods on the wrong class instance.
- Case or spelling typos.
- Forgetting __call magic exists in some frameworks.
Key takeaways
- Call to undefined method: You called a method that the object's class does not define.
- Read the message and the line number first.
- Fix the cause, don't just silence the error.
FAQ
How do I list available methods?
get_class_methods($obj).
How do I find which line caused Call to undefined method?
The error message and stack trace show the file and line; start there and work backwards.