欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PHP动态输出JavaScript代码实例

程序员文章站 2022-11-15 12:48:43
直接上代码: $url = $this->getconfig ()->url (); $content = "var url={ base:'{$u...

直接上代码:

$url = $this->getconfig ()->url ();
$content = "var url={ base:'{$url->base}',css:'{$url->css}',js:'{$url->js}',img:'{$url->img}',current:window.location};";
$expire = 604800;
header ( 'content-type: application/x-javascript' );
header ( 'cache-control: max-age=' . $expire );
header ( 'accept-ranges: bytes' );
header ( 'content-length: ' . strlen ( $content ) );
echo $content;