Home  >  Article  >  Backend Development  >  怎么指定时间段内禁止运行

怎么指定时间段内禁止运行

WBOY
WBOYOriginal
2016-06-23 14:04:531263browse

比如一个页面,我指定每天的晚8点到早8点间禁止打开,怎么处理


回复讨论(解决方案)

只能够判断当前的时间,如果时间在限制时间内的话 那么就直接跳转回上一页。

这个看起来简单,但实际上有点复杂,真没人会吗

PHP开头判断一下时间,这个不难吧

开始处加入

if(date('G') < 8 || date('G') > 20) {  header("Location: http://$_SERVER[HTTP_HOST]/");   exit;}

楼上正解!

在程序开头处判断一下时间就可以了,如果不符合时间要求,就跳转到一个禁止页面或者直接停止页面执行

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