Call to a member function foo() on a non-object

From Php

Jump to: navigation, search

You can get errors like

  Call to a member function bar() on a non-object in Foo.php on line 193

if you misspell the name of the object.

WRONG

 $color = new Colour();  // u missing from "colour"
 $colour->foo();

RIGHT

 $colour = new Colour(); // u inserted, now they match
 $colour->foo();