I’m trying to include a class in PHP and to use the methods from this class in another file. My code looks like that (small reproducable example). By the way: I’m working on a WordPress environment.
Main file:
include 'class-file.php';
$cars = new Cars();
var_dump($cars->getCars());
File class-file.php:
class Cars {
public function getCars() {
return "No Cars";
}
}
I get the following error:
Fatal error: Uncaught Error: Call to undefined method Cars::load() in /..../wp-content/themes/builder/includes/elements.php
Seems that my class instance is connected with another class from the theme. But why? Can I disconnect the class from any others? If yes, how?