So I have this problem where I can call an object method statically and vice versa. Is this supposed to happen or what am I doing wrong in case?
PHP Version: 5.6.12 XAMPP Version: 3.2.1
function endl()
{
echo "<br>";
}
class Base
{
public function objectFunc($msg)
{
echo "You called a non-static function from " . $msg;
endl();
}
public static function staticFunc($msg)
{
echo "You called a static function from " . $msg;
endl();
}
}
Base::objectFunc("a static call");
Base::staticFunc("a static call");
$base = new Base;
$base->objectFunc("a non-static call");
$base->staticFunc("a non-static call");
Here are the results from running this:
You called a non-static function from a static call
You called a static function from a static call
You called a non-static function from a non-static call
You called a static function from a non-static call