故意减慢HTML / PHP页面加载到测试 [英] Intentionally Slow Down HTML/PHP Page Load to Test

查看:226
本文介绍了故意减慢HTML / PHP页面加载到测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇是否存在故意减慢页面加载速度的方法?

I'm curious if there exists a method to intentionally slow the page load?

我正在测试我的HTML&我的本地主机上的PHP页面现在,我想知道当页面加载速度较慢时我的加载gif等将如何执行。

I'm testing my HTML & PHP pages on my local host right now, and I want to see how my loading gif etc will perform when the page load is slower.

我意识到这是一个罕见的请求因为大多数开发人员只关心加速 up 页面加载,但我认为可能有一种方法,使用javascript / jQuery或PHP,为测试目的做这样的事情。

I realize this is a rare request as most developers are only concerned with speeding up page loads, but I thought there might be a method, using either javascript/jQuery or PHP, to do something like this for testing purposes.

感谢您的帮助!

注意:我正在测试MAMP,因此运行的是Apache服务器Mac OS 10.7

Note: I'm testing on MAMP, so that's Apache server running on Mac OS 10.7

推荐答案

你可以使用php的 sleep($ seconds) 降低页面加载速度的功能。但是,您需要将隐式输出缓冲区刷新为打开 使用 ob_implicit_flush(true); 如果您希望在页面处理完成之前将任何内容发送到用户的浏览器。否则,在完成加载之前,您的页面将不会包含任何内容。单独打电话睡觉是不行的。

You can use php's sleep($seconds) function to slow down a page load. However, you would need to turn implicit output buffer flushing to "on" with ob_implicit_flush(true); if you want anything to be sent to the user's browser before the page is done being processed. Otherwise your page won't have ANY contents until it's done loading. Calling sleep alone won't do the trick.

这篇关于故意减慢HTML / PHP页面加载到测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆