<?php
class MyClass
{
static function test()
{
echo "Victor";
}
static function result()
{
echo "My name is ".self::test();
}
}
MyClass::result();
?>
I’m confused why self::test() is executed before the rest of the command or the other way around. Thanks in advance for the comments.
Because to get string that needs to be echoed out needs to be “prepared”. so before output it needs to know what’s the return value of it. it executes first and it’s result is included in string. Actually,
self::test();does not return value, but echoes out some text.