{"id":4880,"date":"2011-09-11T20:14:13","date_gmt":"2011-09-11T11:14:13","guid":{"rendered":"http:\/\/www.gesource.jp\/weblog\/?p=4880"},"modified":"2017-07-16T12:40:30","modified_gmt":"2017-07-16T03:40:30","slug":"php%e3%81%ae%e5%8b%89%e5%bc%b7%e3%81%ab%e3%80%8c10-life-saving-php-snippets%e3%80%8d%e3%81%a7%e7%b4%b9%e4%bb%8b%e3%81%95%e3%82%8c%e3%81%a6%e3%81%84%e3%82%8b%e3%82%b3%e3%83%bc%e3%83%89%e3%82%92-3","status":"publish","type":"post","link":"https:\/\/www.gesource.jp\/weblog\/?p=4880","title":{"rendered":"PHP\u306e\u52c9\u5f37\u306b\u300c10 Life-Saving PHP Snippets\u300d\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u30b3\u30fc\u30c9\u3092\u8aad\u3093\u3067\u307f\u308b\u3002(Compress multiple CSS files)"},"content":{"rendered":"<p>PHP\u306e\u52c9\u5f37\u306b\u300c<a href=\"http:\/\/css.dzone.com\/news\/10-life-saving-php-snippets\">10 Life-Saving PHP Snippets<\/a>\u300d\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u30b3\u30fc\u30c9\u3092\u8aad\u3093\u3067\u307f\u308b\u3002<\/p>\n<ul>\n<li><a href=\"http:\/\/css.dzone.com\/news\/10-life-saving-php-snippets\">10 Life-Saving PHP Snippets<\/a><\/li>\n<\/ul>\n<p>\u25a0Compress multiple CSS files(\u8907\u6570CSS\u30d5\u30a1\u30a4\u30eb\u306e\u5727\u7e2e)<\/p>\n<p>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u6b21\u306e\u3088\u3046\u306a\u3082\u306e\u3002<\/p>\n<pre><code>header('Content-type: text\/css');\nob_start(\"compress\");\nfunction compress($buffer) {\n  \/* remove comments *\/\n  $buffer = preg_replace('!\/\\*[^*]*\\*+([^\/][^*]*\\*+)*\/!', '', $buffer);\n  \/* remove tabs, spaces, newlines, etc. *\/\n  $buffer = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\", \"\\t\", '  ', '    ', '    '), '', $buffer);\n  return $buffer;\n}\n\n\/* your css files *\/\ninclude('master.css');\ninclude('typography.css');\ninclude('grid.css');\ninclude('print.css');\ninclude('handheld.css');\n\nob_end_flush();\n<\/code><\/pre>\n<p>\u8907\u6570\u306eCSS\u30d5\u30a1\u30a4\u30eb\u3092\u4e00\u3064\u306b\u307e\u3068\u3081\u3001\u6539\u884c\u30b3\u30fc\u30c9\u3084\u9023\u7d9a\u3059\u308b\u7a7a\u767d\u6587\u5b57\u306a\u3069\u3092\u524a\u9664\u3057\u3066\u51fa\u529b\u3059\u308b\u3002<\/p>\n<p>\u25a0\u89e3\u8aac<\/p>\n<pre><code>ob_start(\"compress\");\n<\/code><\/pre>\n<p>ob_start\u95a2\u6570\u306f\u51fa\u529b\u306e\u30d0\u30c3\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u6709\u52b9\u306b\u3059\u308b\u3002<br \/>\n\u6700\u521d\u306e\u5f15\u6570\u306f\u3001\u30d0\u30c3\u30d5\u30a1\u3092\u51fa\u529b\u3059\u308b\u6642\u306b\u547c\u3070\u308c\u308b\u95a2\u6570\u3002<br \/>\n\u3053\u306e\u95a2\u6570\u306f\u51fa\u529b\u30d0\u30c3\u30d5\u30a1\u306e\u5185\u5bb9\u3092\u5f15\u6570\u3068\u3057\u3066\u53d7\u3051\u53d6\u308a\u3001\u51fa\u529b\u7d50\u679c\u3092\u8fd4\u3059\u3002<\/p>\n<pre><code>function compress($buffer) {\n  \/* remove comments *\/\n  $buffer = preg_replace('!\/\\*[^*]*\\*+([^\/][^*]*\\*+)*\/!', '', $buffer);\n  \/* remove tabs, spaces, newlines, etc. *\/\n  $buffer = str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\", \"\\t\", '  ', '    ', '    '), '', $buffer);\n  return $buffer;\n}\n<\/code><\/pre>\n<p>compress\u95a2\u6570\u306f\u30d0\u30c3\u30d5\u30a1\u3092\u51fa\u529b\u3059\u308b\u6642\u306b\u547c\u3073\u51fa\u3055\u308c\u308b\u3002<br \/>\n\u3053\u306e\u95a2\u6570\u306f\u3001CSS\u306e\u30b3\u30e1\u30f3\u30c8\u3068\u6539\u884c\u30b3\u30fc\u30c9\u3084\u30bf\u30d6\u6587\u5b57\u3001\u9023\u7d9a\u3059\u308b\u7a7a\u767d\u6587\u5b57\u3092\u524a\u9664\u3057\u3066\u3044\u308b\u3002<\/p>\n<pre><code>\/* your css files *\/\ninclude('master.css');\ninclude('typography.css');\ninclude('grid.css');\ninclude('print.css');\ninclude('handheld.css');\n<\/code><\/pre>\n<p>include()\u306f\u6307\u5b9a\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f\u3001\u8a55\u4fa1\u3059\u308b\u3002<br \/>\n\u3053\u3053\u3067\u306fCSS\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f\u3001CSS\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u51fa\u529b\u30d0\u30c3\u30d5\u30a1\u306b\u5165\u308c\u3066\u3044\u308b\u3002<\/p>\n<pre><code>ob_end_flush();\n<\/code><\/pre>\n<p>ob_end_flush()\u306f\u51fa\u529b\u7528\u30d0\u30c3\u30d5\u30a1\u3092\u9001\u4fe1\u3059\u308b\u3002<\/p>\n<p>include()\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307fob_start()\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u3067\u51e6\u7406\u3092\u884c\u3063\u3066\u51fa\u529b\u3059\u308b\u3068\u3044\u3046\u65b9\u6cd5\u306f\u3001CSS\u30d5\u30a1\u30a4\u30eb\u306e\u5727\u7e2e\u4ee5\u5916\u306e\u7528\u9014\u306b\u3082\u4f7f\u3048\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u3002<\/p>\n<div class=\"booklink-box\" style=\"text-align:left;padding:20px;font-size:small;\/zoom: 1;overflow: hidden;\">\n<div class=\"booklink-image\" style=\"float:left;margin:0 15px 10px 0;\"><a href=\"http:\/\/www.amazon.co.jp\/exec\/obidos\/asin\/4798119865\/gesource-22\/\" name=\"booklink\" rel=\"nofollow\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/ecx.images-amazon.com\/images\/I\/518bklf0j0L._SL160_.jpg?w=730\" style=\"border: none;\" \/><\/a><\/div>\n<div class=\"booklink-info\" style=\"line-height:120%;\/zoom: 1;overflow: hidden;\">\n<div class=\"booklink-name\" style=\"margin-bottom:10px;line-height:120%\"><a href=\"http:\/\/www.amazon.co.jp\/exec\/obidos\/asin\/4798119865\/gesource-22\/\" name=\"booklink\" rel=\"nofollow\" target=\"_blank\">PHP \u9006\u5f15\u304d\u30ec\u30b7\u30d4 (PROGRAMMER\u2019S RECiPE)<\/a><\/p>\n<div class=\"booklink-powered-date\" style=\"font-size:8pt;margin-top:5px;font-family:verdana;line-height:120%\">posted with <a href=\"http:\/\/yomereba.com\" target=\"_blank\">\u30e8\u30e1\u30ec\u30d0<\/a><\/div>\n<\/div>\n<div class=\"booklink-detail\" style=\"margin-bottom:5px;\">\u9234\u6728 \u61b2\u6cbb \u7fd4\u6cf3\u793e 2009-06-30    <\/div>\n<div class=\"booklink-link2\" style=\"margin-top:10px;\">\n<div class=\"shoplinkamazon\" style=\"margin-right:5px;background: url('http:\/\/img.yomereba.com\/yl.gif') 0 0 no-repeat;padding: 2px 0 2px 18px;white-space: nowrap;\"><a href=\"http:\/\/www.amazon.co.jp\/exec\/obidos\/asin\/4798119865\/gesource-22\/\" rel=\"nofollow\" target=\"_blank\" title=\"\u30a2\u30de\u30be\u30f3\" >Amazon\u3067\u8abf\u3079\u308b<\/a><\/div>\n<div class=\"shoplinkrakuten\" style=\"margin-right:5px;background: url('http:\/\/img.yomereba.com\/yl.gif') 0 -50px no-repeat;padding: 2px 0 2px 18px;white-space: nowrap;\"><a href=\"http:\/\/pt.afl.rakuten.co.jp\/c\/09af7168.5e4175d8\/?url=http%3A%2F%2Fbooks.rakuten.co.jp%2Frb%2F6108918%2F\" rel=\"nofollow\" target=\"_blank\" title=\"\u697d\u5929\u5e02\u5834\" >\u697d\u5929\u30d6\u30c3\u30af\u30b9\u3067\u8abf\u3079\u308b<\/a><\/div>\n<div class=\"shoplinkbookoff\" style=\"margin-right:5px;background: url('http:\/\/img.yomereba.com\/yl.gif') 0 -200px no-repeat;padding: 2px 0 2px 18px;white-space: nowrap;\"><a href=\"http:\/\/click.linksynergy.com\/fs-bin\/click?id=aEiZExlwPrs&#038;subid=&#038;offerid=169505.1&#038;type=10&#038;tmpid=3677&#038;RD_PARM1=http%253A%252F%252Fwww.bookoffonline.co.jp%252Fdisplay%252FL001%252Cbg%253D12%252Cq%253D9784798119861\" rel=\"nofollow\" target=\"_blank\" title=\"\u30d6\u30c3\u30af\u30aa\u30d5\u30aa\u30f3\u30e9\u30a4\u30f3\" >\u30d6\u30c3\u30af\u30aa\u30d5\u3067\u8abf\u3079\u308b<\/a><\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>PHP\u306e\u52c9\u5f37\u306b\u300c10 Life-Saving PHP Snippets\u300d\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u30b3\u30fc\u30c9\u3092\u8aad\u3093\u3067\u307f\u308b\u3002 10 Life-Saving PHP Snippets \u25a0Compress multiple CSS file &#8230;<\/p>\n<p><a href=\"https:\/\/www.gesource.jp\/weblog\/?p=4880\" class=\"more-link\">Continue reading &lsquo;PHP\u306e\u52c9\u5f37\u306b\u300c10 Life-Saving PHP Snippets\u300d\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u30b3\u30fc\u30c9\u3092\u8aad\u3093\u3067\u307f\u308b\u3002(Compress multiple CSS files)&rsquo; &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[25],"tags":[151],"class_list":["post-4880","post","type-post","status-publish","format-standard","hentry","category-php","tag-php"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/4880","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4880"}],"version-history":[{"count":0,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/4880\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gesource.jp\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}