PHP js CSS Load merge function Song Jong finishing

Source: Internet
Author: User

<?php//php js css load Merge function   Song Jong finishing//reprint please specify the source define (' Combine_js ', true);d efine (' Combine_css ', true);  define (' Application_js_root ', ' e:/wwwroot/m/js/');d efine (' application_css_root ', ' e:/wwwroot/m/css/');  define (' Sc_root ', ' e:/wwwroot/m/static_cache/');d efine (' Sc_url ', ' http://www.localhost.com/m/static_cache/  define (' Application_js ', ' http://www.localhost.com/m/js/');d efine (' application_css ', ' http:// www.localhost.com/m/css/');  function load_combine_js ($js, $path =array (), $origin =false, $part =1) {     if (!is_array ($JS))  return false;    if (Empty ($path)) {          $path _url=application_js;          $path _root=application_js_root;    }    if ($origin  or  (! COMBINE_JS)) {         $string = ";         for ($i =0; $i <coUNT ($JS); $i + +) {$string. = ' <script src= ' {$path _url}{$js [$i]}.js ' ></script>\n ';}         echo  $string;         return true;    }     $cache _filename= ' js-'. MD5 ($_server[' Script_name ']. $part). '. JS ';     if (!file_exists (sc_root. $cache _filename)) {          $file _content= ';         for ($i =0; $i <count ($JS); $i + +) {              $f = $path _root. $js [$i]. '. JS ';             if (file_exists ($f))   $file _ Content.=file_get_contents ($f). " \ n ";         }        file_put_ Contents (sc_root. $cache _filename, $file _content);    }     $file =sc_uRL. $cache _filename;    echo  "<script src= ' {$file} ' ></script>\n";     return true;}  function load_combine_css ($css, $path =array (), $origin =false, $part =1) {    if (!is_ Array ($CSS))  return false;    if (Empty ($path)) {          $path _url=application_css;         $path _root= Application_css_root;    }    if ($origin  or  (! COMBINE_CSS)) {         $string = ";         for ($i =0; $i <count ($CSS); $i + +) {$string. = ' <link href= ' {$path _url}{$css [$i]}.css '  rel = ' stylesheet '  type= ' text/css '  />\n ';}         echo  $string;         return true;    }     $cache _filename= ' css-'. MD5 ($_server[' Script_name ']. $part). CSS ';     if (!file_exists (sc_root. $cache _filename)) {          $file _content= ';         for ($i =0; $i <count ($CSS); $i + +) {              $f = $path _root. $css [$i]. '. CSS ';             if (file_exists ($f))   $file _ Content.=file_get_contents ($f). " \ n ";         }        file_put_ Contents (sc_root. $cache _filename, $file _content);    }     $file =sc_url. $cache _filename;    echo  $string = "<link href= ' {$file} '  rel= ' stylesheet '  type= ' text/css '  />\n ";     return true;}  ?><! doctype html public  "-//w3c//dtd&nbSp xhtml 1.0 transitional//en " " HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD ">< html xmlns= "http://www.w3.org/1999/xhtml" >

PHP js CSS load merge function Song Jong collation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.