Here's one way you could do some lazy evaluation:
<?php
$_GET["title"] = ""; // faking a GET with a missing title
function title($page)
{
$title = htmlentities($_GET["title"]);
return $page . ' - ' . ($title = $title?: 'missing title');
}
echo title( htmlentities( $_SERVER['SCRIPT_NAME'] ) );
?>
If there's any kind of a title it will display but if it's missing, then user gets notified. I make use of the '?:' operator which assures that $title gets assigned the value of the right-hand operand, if $title holds a false value. Note, generally PHP does not make use of lazy evaluation outside of working with Booleans and the logical as well as bit-wise operators. Altho' there is the odd case of passing an argument when attempting to instantiate a class that lacks a constructor in which case while an opcode gets generated pertaining to that argument, it never executes and so the expression never evaluates.