I'm using php, and the following line produces an error I've not been able to fix:
self::$connection = DatabaseConnection::getConnection();
I'm using php, and the following line produces an error I've not been able to fix:
self::$connection = DatabaseConnection::getConnection();
The message is telling you that DatabaseConnection->getConnection();
is not a static method.
The difference is that static methods are called on a class and using the ::
operator. Non-static methods (instance methods), are called on an instance of the class and using the ->
operator.
PHP allowed non-static methods to be called in a static way, as long as they don't use any instance properties. With error reporting set to strict, it will throw this error though.
To solve it, either create a DatabaseConnection
instance to call the method on, or change its declaration to static
if it should be a static method.
You can also make error reporting less strict, but that's the wrong way to solve it in my book,