TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How to Compress CSS File using PHP
Bhushan Singh
Jan 15
2015
Code
2
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
compress.zip
<?php
header(
'Content-type: text/css'
);
ob_start(
"compress"
);
function
compress(
$buffer
) {
$buffer
= preg_replace(
'!/\*[^*]*\*+([^/][^*]*\*+)*/!'
,
''
,
$buffer
);
$buffer
=
str_replace
(
array
(
"\r\n"
,
"\r"
,
"\n"
,
"\t"
,
' '
,
' '
,
' '
),
''
,
$buffer
);
return
$buffer
;
}
/* your css files */
include
(
'style.css'
);
include
(
'css/style.css'
);
?>
compress css file using php
css
php