★ wanayoo — archive 1999 http://uk.php.net/manual/sv/function.touch.phpNouvelle recherche | Portail wanayoo
PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<tmpfileumask>
view the version of this page
Last updated: Thu, 24 Apr 2003

touch

(PHP 3, PHP 4 )

touch -- Sets access and modification time of file

Description

int touch ( string filename [, int time [, int atime]])

Attempts to set the access and modification time of the file named by filename to the value given by time. If the option time is not given, uses the present time. This is equivalent to what utime (sometimes referred to as utimes) does. If the third option atime is present, the access time of the given filename is set to the value of atime. Note that the access time is always modified, regardless of the number of parameters.

If the file does not exist, it is created.

Returnerar TRUE vid framgång eller FALSE vid fel.

Exempel 1. touch() example

if (touch ($FileName)) {
    print "$FileName modification time has been 
           changed to todays date and time";
} else {
    print "Sorry Could Not change modification time of $FileName";
}



User Contributed Notes
touch
add a note add a note
master at dreamphp dot com
15-May-2001 05:23

$filename = "test.dat";
if (!file_exists($filename)) {
touch($filename); // Create blank file
 chmod($filename,0666);
}

emilebosch at hotmail dot com
06-Oct-2001 09:41

To spare you ppl couple of hours of valuable time, you can only TOUCH a file that you own! Usually PHP is *nobody*
Warm regards,
Emile Bosch

feathern at yahoo dot com
13-Aug-2002 09:31

Neat little script that will give you a list of all modified files in a certain folder after a certain date:

$filelist = Array();
$filelist = list_dir("d:\\my_folder");
for($i=0;$i<count($filelist);$i++){
$test = Array();
$test = explode("/",date("m/d/Y",filemtime($filelist[$i])));
//example of files that are later then
//06/17/2002
if(($test[2] > 2001) && ($test[1] > 16) && ($test[0] > 5)){
echo $filelist[$i]."\r\n";
}
clearstatcache();
}
function list_dir($dn){
if($dn[strlen($dn)-1] != '\\') $dn.='\\';
static $ra = array();
$handle = opendir($dn);
while($fn = readdir($handle)){
if($fn == '.' || $fn == '..') continue;
if(is_dir($dn.$fn)) list_dir($dn.$fn.'\\');
else $ra[] = $dn.$fn;
}
closedir($handle);
return $ra;
}

add a note add a note

<tmpfileumask>
 Last updated: Thu, 24 Apr 2003
show source | credits | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by: Kewlio.net Limited
Last updated: Sat Jun 7 04:10:06 2003 BST