Идеята е да се премахнат някои излишни байтове в output html през php
Без обяснения, а директно с пример:
<?php
ob_start();
echo „line 1
line 4
line 6
line 10″;
$search = array(
‘/\>[^\S ]+/s’, //strip whitespaces after tags, except space
‘/[^\S ]+\</s’, //strip whitespaces before tags, except space
‘/(\s)+/s’ // shorten multiple whitespace sequences
);
$replace = array(
‘>’,
‘<‘,
‘\\1’
);
$output = ob_get_contents();
$output = preg_replace($search, $replace, $output);
ob_end_clean();
echo $output;exit;
?>
Вижда се, че вместо да се листнат 10 реда(в сорса разбира се) се листват 4 реда 😉
Logged in as {{omniform_current_user_display_name}}. Edit your profile. Log out? Required fields are marked *
Your email address will not be published. Required fields are marked *
Comments are closed.
You must be logged in to post a comment.