クラス変数でスコープ解決演算子を使用すると致命的なphpエラーが発生する理由と、それを回避する方法があるかどうかについて知りたいです。
例えば:
<?php
class StaticTest
{
public static function output()
{
echo "Output called<br />";
}
}
Class Test
{
public $reference;
public function __construct()
{
$this -> reference = new StaticTest;
}
}
$static_test = new StaticTest;
$static_test::output(); //works as intended
$test = new Test;
$test -> reference::output(); //Unexpcted T_PAAMAYIM_NEKUDOTAYIM
$direct_reference = $test -> reference;
$direct_reference::output(); //works, closest solution i have found, but requires the extra line of code / variable
?>