Вы можете использовать эту функцию вместо:
function notification($text, $info = FALSE, $title = FALSE) {
global $layout_name;
echo '<div class="SmallBox"><div class="MessageContainer"><div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div> <div class="BoxFrameEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div><div class="BoxFrameEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div><div class="'.($info ? "Valid" : "Error").'Message"><div class="BoxFrameVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div><div class="BoxFrameVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div><div class="AttentionSign" style="background-image:url('.$layout_name.'/images/content/'.(!$info ? 'attentionsign.gif' : 'valid.png').');" /></div><b>'.(!$title ? (!$info ? 'Wystąpiły następujące błędy:' : 'Sukces!') : $title).'</b><br/>'.$text.'</div><div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div> <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div><div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div></div></div>';
}
, но она все еще повторяет результаты, невозможно избежать использования функции echo
.
PASSING BYREF
функция будет выглядеть примерно так, как показано ниже, но вы должны изменить ее в соответствии со своими потребностями:
function notification($text, $info = FALSE, $title = FALSE, &$content) {
global $layout_name;
$content .= '<div class="SmallBox"><div class="MessageContainer"><div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div> <div class="BoxFrameEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div><div class="BoxFrameEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div><div class="'.($info ? "Valid" : "Error").'Message"><div class="BoxFrameVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div><div class="BoxFrameVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></div><div class="AttentionSign" style="background-image:url('.$layout_name.'/images/content/'.(!$info ? 'attentionsign.gif' : 'valid.png').');" /></div><b>'.(!$title ? (!$info ? 'Wystąpiły następujące błędy:' : 'Sukces!') : $title).'</b><br/>'.$text.'</div><div class="BoxFrameHorizontal" style="background-image:url('.$layout_name.'/images/content/box-frame-horizontal.gif);" /></div> <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div><div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></div></div></div>';
}
Теперь, если вы используете эту функцию и передаете$content
переменная, она изменит содержимое $ вне функции.обратите внимание, что передача по ссылке осуществляется в php путем добавления &
перед переменной $VAR
.