Home  >  Article  >  Backend Development  >  Example of php merging js requests_PHP tutorial

Example of php merging js requests_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:25:31875browse

A small example that you can learn by looking at the code: php merge js request

Copy the code The code is as follows:

//Page Save as js.php
//Foreground request example http://localhost/js.php?f=1,2
//Request two files 1.js and 2.js
header("Content-Type:application/x-javascript");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: max-age=".(86400*30));
header("Expires: " .gmdate("D, d M Y H:i:s",time()+ 86400*30). "GMT");

if($_GET['f'])
{
$url = parse_url($_SERVER['REQUEST_URI']);

$arr_f = array_unique(explode(',' ,preg_replace("/.+//",'',$_GET['f'])));

foreach($arr_f as $v)
{
if(!empty($v))
{
include('./'.$v.'.js');
echo "n";
}
}
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825023.htmlTechArticleA small example that you can learn by looking at the code: php merge js request copy code The code is as follows: //Save the page as js. php //Foreground request example http://localhost/js.php?f=1,2 //Request two files 1.js and 2.js?PH...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn