Tipik olarak, bu yüzden gibi bir işlevi yazacağım:
function alertClass($field,$full=false){
global $formErrors;
$html = $full ? ' class="alert"' : ' alert';
if (!empty($formErrors[$field])) return $html;
}
Ben html göstermek istediğiniz yere ve sonra ben gibi işlevin dönüş değerini echo:
echo alertClass('somefield')
but today I was thinking why not just put the echo in the function instead of using it's return value? So instead of "return $html" it would be "echo $html"... Is there an advantage to one way or the other?