Php merge js request example _ PHP Tutorial

Source: Internet
Author: User
Example of php merge js requests. Let's take a look at the code. for example: php merging js requests to copy code Code: The page is saved as a js. php foreground request example localhostjs. php? F1, 2 request two files: 1.js, 2. js? A small example of php merging js requests.

The code is as follows:


// Save the page as js. php
// Front-end request example http: // localhost/js. php? F = 1, 2
// Request two files: 1.jsand 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 ";
}
}
}
?>

The response code is as follows: // The page is saved as js. php // frontend request example http: // localhost/js. php? F = 1, 2 // request two files: 1.js, 2. js? PH...

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.