3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyParent { const NAVIGATION = 'nav'; public static function getUri() { static $uri = null; if ($uri === null) { echo 'null<br>'; $uri = 'test '.static::NAVIGATION; } return $uri; } } class FirstChild extends MyParent { } class SecondChild extends MyParent { const NAVIGATION = 'childnav'; } $first = new FirstChild(); $second = new SecondChild(); echo '<pre>', var_export($first->getUri(), true), '</pre>'; echo '<pre>', var_export($second->getUri(), true), '</pre>'; echo '<pre>', var_export($first->getUri(), true), '</pre>'; echo '<pre>', var_export($second->getUri(), true), '</pre>';

preferences:
62.01 ms | 402 KiB | 5 Q