PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
class CalledClass
{
function go2()
{
echo "hello world";
}
}
class CallerClass
{
function go()
{
CalledClass::go2();
}
}
$obj = new CallerClass();
$obj->go();
How is it possible that the double colon let me go inside the method of that independent class (not base class) without any problems? Isn't the double colon just used for static and constants?
My doubts are related to the need of using "static" in order to access a method without creating an object. For example, this following code works, without creating the method static:
PHP should be issuing a warning (but not a fatal error) when you try to access a non static method as static. I suggest you turn on display_errors and set error_reporting to the strictest level