$if = function($test, $true, $false) { return $test ? $true : $false; }; echo "class='{$if(true, 'abc', 'def')}'";