Return to Snippet

Revision: 46310
at May 17, 2011 07:13 by giak


Updated Code
/* in .htaccess */
AddType application/x-httpd-php .css // to parse PHP var

/* on root CSS folder */
<?php
ob_start("ob_gzhandler");
ob_start("compress");
Header("Content-type:text/css;charset=utf-8");
function compress($buffer) {
// remove comments
    $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
// remove tabs, spaces, new lines
    $buffer = str_replace(array("
", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
// remove spaces 
    $buffer = str_replace('{ ', '{', $buffer);
    $buffer = str_replace(' }', '}', $buffer);
    $buffer = str_replace('; ', ';', $buffer);
    $buffer = str_replace(', ', ',', $buffer);
    $buffer = str_replace(' {', '{', $buffer);
    $buffer = str_replace('} ', '}', $buffer);
    $buffer = str_replace(': ', ':', $buffer);
    $buffer = str_replace(' ,', ',', $buffer);
    $buffer = str_replace(' ;', ';', $buffer);
return $buffer;
}

// include your PHP vars
include 'cssvar.php';

// and insert all your CSS files
include 'reset.css';
?>


/* in CSSVAR.PHP */
<?php
$v_css_gradient_blue = "
	background: #b8c1d7;
	background: -webkit-gradient(linear, left top, left bottom, from(#dae3ee), to(#b8c1d7));
	background: -moz-linear-gradient(top,  #dae3ee,  #b8c1d7);
	filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#dae3ee', endColorstr='#b8c1d7');
";
?>


/* Use in CSS files */
h1{
padding:0 0 15px 0;
margin:0;
font-size:180%;
<?php echo $v_css_gradient_blue;?>
}

Revision: 46309
at May 17, 2011 07:11 by giak


Updated Code
/* in .htaccess */
AddType application/x-httpd-php .css

/* on root CSS folder */
<?php
ob_start("ob_gzhandler");
ob_start("compress");
Header("Content-type:text/css;charset=utf-8");
function compress($buffer) {
// remove comments
    $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
// remove tabs, spaces, new lines
    $buffer = str_replace(array("
", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
// remove spaces 
    $buffer = str_replace('{ ', '{', $buffer);
    $buffer = str_replace(' }', '}', $buffer);
    $buffer = str_replace('; ', ';', $buffer);
    $buffer = str_replace(', ', ',', $buffer);
    $buffer = str_replace(' {', '{', $buffer);
    $buffer = str_replace('} ', '}', $buffer);
    $buffer = str_replace(': ', ':', $buffer);
    $buffer = str_replace(' ,', ',', $buffer);
    $buffer = str_replace(' ;', ';', $buffer);
return $buffer;
}

// include your PHP vars
include 'cssvar.php';

// and insert all your CSS files
include 'reset.css';
?>


/* in CSSVAR.PHP */
<?php
$v_css_gradient_blue = "
	background: #b8c1d7;
	background: -webkit-gradient(linear, left top, left bottom, from(#dae3ee), to(#b8c1d7));
	background: -moz-linear-gradient(top,  #dae3ee,  #b8c1d7);
	filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#dae3ee', endColorstr='#b8c1d7');
";
?>


/* Use in CSS files */
h1{
padding:0 0 15px 0;
margin:0;
font-size:180%;
<?php echo $v_css_gradient_blue;?>
}

Revision: 46308
at May 17, 2011 07:08 by giak


Updated Code
/* in .htacess */
AddType application/x-httpd-php .css

/* on root CSS folder */
<?php
ob_start("ob_gzhandler");
ob_start("compress");
Header("Content-type:text/css;charset=utf-8");
function compress($buffer) {
// remove comments
    $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
// remove tabs, spaces, new lines
    $buffer = str_replace(array("
", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
// remove spaces 
    $buffer = str_replace('{ ', '{', $buffer);
    $buffer = str_replace(' }', '}', $buffer);
    $buffer = str_replace('; ', ';', $buffer);
    $buffer = str_replace(', ', ',', $buffer);
    $buffer = str_replace(' {', '{', $buffer);
    $buffer = str_replace('} ', '}', $buffer);
    $buffer = str_replace(': ', ':', $buffer);
    $buffer = str_replace(' ,', ',', $buffer);
    $buffer = str_replace(' ;', ';', $buffer);
return $buffer;
}

// include your PHP vars
include 'cssvar.php';

// and insert all your CSS files
include 'reset.css';
?>


/* in CSSVAR.PHP */
<?php
$v_css_gradient_blue = "
	background: #b8c1d7;
	background: -webkit-gradient(linear, left top, left bottom, from(#dae3ee), to(#b8c1d7));
	background: -moz-linear-gradient(top,  #dae3ee,  #b8c1d7);
	filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#dae3ee', endColorstr='#b8c1d7');
";
?>


/* Use in CSS files */
h1{
padding:0 0 15px 0;
margin:0;
font-size:180%;
<?php echo $v_css_gradient_blue;?>
}

Revision: 46307
at May 17, 2011 07:07 by giak


Updated Code
/* in .htacess */
AddType application/x-httpd-php .css

/* on root CSS folder */
<?php
ob_start("ob_gzhandler");
ob_start("compress");
Header("Content-type:text/css;charset=utf-8");
function compress($buffer) {
// remove comments
    $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
// remove tabs, spaces, new lines
    $buffer = str_replace(array("
", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
// remove spaces 
    $buffer = str_replace('{ ', '{', $buffer);
    $buffer = str_replace(' }', '}', $buffer);
    $buffer = str_replace('; ', ';', $buffer);
    $buffer = str_replace(', ', ',', $buffer);
    $buffer = str_replace(' {', '{', $buffer);
    $buffer = str_replace('} ', '}', $buffer);
    $buffer = str_replace(': ', ':', $buffer);
    $buffer = str_replace(' ,', ',', $buffer);
    $buffer = str_replace(' ;', ';', $buffer);
return $buffer;
}

// include your PHP vars
include 'cssvar.php';

// and insert all your CSS files
include 'reset.css';
?>


/* in CSSVAR.PHP */
<?php
$v_css_gradient_blue = "
	background: #b8c1d7;
	background: -webkit-gradient(linear, left top, left bottom, from(#dae3ee), to(#b8c1d7));
	background: -moz-linear-gradient(top,  #dae3ee,  #b8c1d7);
	filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#dae3ee', endColorstr='#b8c1d7');
?>


/* Use in CSS files */
h1{
padding:0 0 15px 0;
margin:0;
font-size:180%;
<?php echo $v_css_gradient_blue;?>
}

Revision: 46306
at May 17, 2011 07:06 by giak


Initial Code
/* in .htacess */
AddType application/x-httpd-php .css

/* on root CSS folder */
<?php
ob_start("ob_gzhandler");
ob_start("compress");
Header("Content-type:text/css;charset=utf-8");
function compress($buffer) {
// remove comments
    $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
// remove tabs, spaces, new lines
    $buffer = str_replace(array("
", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
// remove spaces 
    $buffer = str_replace('{ ', '{', $buffer);
    $buffer = str_replace(' }', '}', $buffer);
    $buffer = str_replace('; ', ';', $buffer);
    $buffer = str_replace(', ', ',', $buffer);
    $buffer = str_replace(' {', '{', $buffer);
    $buffer = str_replace('} ', '}', $buffer);
    $buffer = str_replace(': ', ':', $buffer);
    $buffer = str_replace(' ,', ',', $buffer);
    $buffer = str_replace(' ;', ';', $buffer);
return $buffer;
}

// include your PHP vars
include 'cssvar.php';

// and insert all your CSS files
include 'reset.css';
?>


/* in CSSVAR.PHP */
<?php
$v_css_gradient_blue = "
	background: #b8c1d7;
	background: -webkit-gradient(linear, left top, left bottom, from(#dae3ee), to(#b8c1d7));
	background: -moz-linear-gradient(top,  #dae3ee,  #b8c1d7);
	filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#dae3ee', endColorstr='#b8c1d7');
?>


/* Use in CSS files */
h1{
padding:0 0 15px 0;
margin:0;
font-size:180%;
<?php echo $v_css_gradient_blue;?>
}
";

Initial URL


Initial Description
compress & combine CSS files and param theme with PHP vars

Initial Title
css minify / combine / param with PHP & Apache (usefull for all)

Initial Tags
css, php, apache

Initial Language
PHP