How to use touch in PHP

In this article I am going to explain about touch function in PHP.
  • 1534

PHP touch() Function

The filesystem touch function sets the access and modification time of the specified file. It specified file does not exists then it will created automatically.

Syntax of touch function

touch(fileName, time, atime)

Parameters in touch function

It have three parameter:

Parameter Description
fileName It specifies the file to touch.
time It specifies the touch time
atime It set access time.

Example of filesystem touch function

<html>

<body>

<?php

$filename="chdir.php";

if (touch($filename))

{

    echo $filename . ' modification time has been changed to present time';

}

else

{

    echo 'Sorry, could not change modification time of ' . $filename;

}

?>

</body>

</html>


Output:

touch-php.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.