易截截图软件、单文件、免安装、纯绿色、仅160KB

php删除文件


如何用php删除文件呢?
php中有个函数叫作unlink。只要一个参数,表示文件路径就行了。
bool unlink ( string filename)
成功删除返回真,否则返回假。
这次我在项目中,需要用到删除文件操作。为了完美的操作,首先要判断一下这个路径的文件是否存在,用file_exists函数。如若存在,则去删除文件。具体代码如下:
if(file_exists($aurls[$i])){
   unlink($aurls[$i]);
  }
其中$aurl[$i]一看就知道是在循环中的一个数组。哈哈,没错,我将所要删除的多个文件的路径存到一个数组中,然后遍历。如果文件存在呢,就删除之。为了更有成就感,我在前后加了两句话,变成了这样:
echo "正在删除".$aurls[$i]."……<br />";
  if(file_exists($aurls[$i])){
   unlink($aurls[$i]);
  }
  echo "成功删除".$aurls[$i]."<hr />";
这样结果就好看了,能明确地看到程序执行结果。


相关文档:

php Mod rewrite test

In the directory where you plan to install Elgg, do the following:
Create the file .htaccess and add these two lines
RewriteEngine on
RewriteRule ^testing.php$ modrewrite.php
This tells the webserver to load modrewrite.php when testing.php is
requested.
In order to get this test to work on ......

PHP获取MSN好友列表类

<?php
/********************************************************************
*   FileName: class.msn.php
*   by changwei, 2010-4-13
*   Contact MSN:  changwei0112@hotmail.com
*    获取MSN好友Email列表 

========================== ......

PHP 正则表达式查找字符串

<?php
set_time_limit(0);
$url='http://item.taobao.com/auction/item_detail.htm?xid=0db2&item_num_id=4512430274&cm_cat=50000671&pm2=1';
$ch = curl_init();
$timeout = 10;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CU ......

php连接mysql

header("Content-Type:text/html;charset=utf8");   放到PHP开头处
$link=mysql_connect("localhost","root","110110");//链接
mysql_select_db("blog",$link);//选择数据库
mysql_query("SET character_set_results=gbk", $link);//字符编码 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号