PHP头条
热点:

或者用到的php代码


可能用到的php代码

1.延迟请求文件,模拟网速不好的时候的场景,代码地址如下:

https://gist.github.com/2650596

?

 'Content-Type: application/x-javascript',
    'css' => 'Content-Type: text/css',
    'jpg' => 'Content-Type: image/jpg',
    'gif' => 'Content-Type: image/gif',
    'png' => 'Content-Type: image/png',
    'jpeg' => 'Content-Type: image/jpeg',
    'swf' => 'Content-Type: application/x-shockwave-flash'
);


$filename = $_GET['f'];
$R_files = file($_GET['f']);

if(empty($type)) {
$type = get_extend($filename);
}

header($header[$type]);

ob_flush();
flush();
sleep($_GET['t']);

//var_dump($R_files);

echo join("\n",$R_files);

?>

?适用方式:

把代码用php文件放到项目目录下,引用目标文件的时候,方式如下:

http://cdn/你的目录/delay.php?f=yourfile.js&t=100

?2.页面逻辑暂停,过一段时间再继续

ob_flush();
flush();
sleep($_GET['t']);

?sleep为php的内置函数,参数为时间,单位秒;要放到PHP后缀的文件下使用,或者要配置下在js文件下使用,或者js后缀的后面加上.php,如 xxx.js.php

?

www.phpzy.comtrue/phprm/52888.htmlTechArticle或者用到的php代码 可能用到的php代码 1.延迟请求文件,模拟网速不好的时候的场景,代码地址如下: https://gist.github.com/2650596 ? 'Content-Type: application/x-javascript', 'css' => 'Content-Type: text/c...

相关文章

PHP之友评论

今天推荐