Horje
How to minify all html in a single line with PHP

Just put following codes of your top of site.

Better to put codes into header.php most top.


PHP Code for minify all html in a single line

Try it into your website.
index.php
Example: PHP
<?php
function minify_output($buffer){ $search = array('/\>[^\S ]+/s','/[^\S ]+\</s','/(\s)+/s'); $replace = array('>','<','\\1'); if (preg_match("/\<html/i",$buffer) == 1 && preg_match("/\<\/html\>/i",$buffer) == 1) { $buffer = preg_replace($search, $replace, $buffer); $buffer = str_replace(array("\r", "\n"), '', $buffer); } return $buffer;
}
ob_start("minify_output");?>

Output should be:





php minify

Type :
Develop
Category :
Web Tutorial
Sub Category :
PHP Function Tutorial
Uploaded by :
Admin