autoexec.php
<?phpignore_user_abort(); //即使Client断开(如关掉浏览器),PHP脚本也可以继续执行.set_time_limit(30); //执行时间为无限制,php默认的执行时间是30秒,通过set_time_limit(0)可以让程序无限制的执行下去$interval=3; //每隔5分钟运行 这个时间间隔可以更改do{ $url = "http://localhost/testUpdate.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 2); $result = curl_exec($ch); curl_close($ch); sleep($interval);// 等待5分钟}while(true);testUpdate.php
<?php $fp = fopen("test.html","a+"); fwrite($fp,time()."一次\n"); fclose($fp);?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号