摘要: 如何用php删除文件呢?php中有个函数叫作unlink。只要一个参数,表示文件路径就行了。bool unlink ( string filename)成功删除返回真,否则返回假。首先要判断一下这个路径的文件是否存在,用file_exists函数。如若存在,则去删除文件。具体代码如下:if(file_exists($aurls[$i])){ unlink($aurls[$i]); }将所要删除的多个文件的路径存到一个数组中,然后遍历。如果文件存在呢,就删除之。为了更有成就感,我在前后加了两句话,变成了这样:for($i=0;$i"; if(file_exists($aurls[$i] 阅读全文
posted @ 2013-09-06 15:26 幸福之家128817 阅读(553) 评论(0) 推荐(0) 编辑
摘要: ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行.set_time_limit(0);// 通过set_time_limit(0)可以让程序无限制的执行下去$interval=60*30;// 每隔半小时运行do{ //这里是你要执行的代码 sleep($interval);// 等待5分钟}while(true);注:对服务器有影响 阅读全文
posted @ 2013-09-06 15:20 幸福之家128817 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 摘自:http://www.oschina.net/code/snippet_943797_19993 阅读全文
posted @ 2013-09-06 15:13 幸福之家128817 阅读(450) 评论(0) 推荐(0) 编辑
摘要: 方法1: 用file_get_contents 以get方式获取内容 方法2:用file_get_contents函数,以post方式获取url 'bar'); $data = http_build_query($data); $opts = array ( 'http' => array ( 'method' => 'POST', 'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . " 阅读全文
posted @ 2013-09-06 15:08 幸福之家128817 阅读(455) 评论(0) 推荐(0) 编辑
摘要: QQ的写法地址:http://www.oschina.net/code/snippet_930167_19888Sina的写法地址:http://www.oschina.net/code/snippet_930167_19891开心网写法地址:http://www.oschina.net/code/snippet_930167_19901豆瓣写法地址:http://www.oschina.net/code/snippet_930167_19903人人网写法地址:http://www.oschina.net/code/snippet_930167_19900 阅读全文
posted @ 2013-09-06 14:58 幸福之家128817 阅读(376) 评论(0) 推荐(0) 编辑