কম্পিউটার টিউটোরিয়াল

PHP-তে touch() ফাংশন


PHP-তে touch() ফাংশনটি একটি ফাইলের অ্যাকসেস এবং মডিফিকেশন টাইম সেট করে। এটি সফল হলে TRUE এবং ব্যর্থ হলে FALSE রিটার্ন করে।

সিনট্যাক্স

touch(filename, time, atime)

প্যারামিটার

  • filename − ফাইলের নাম সেট করুন।

  • time − টাইম সেট করুন। ডিফল্ট হলো বর্তমান সিস্টেম টাইম।

  • atime − অ্যাকসেস টাইম সেট করুন। ডিফল্ট হলো বর্তমান সিস্টেম টাইম।

রিটার্ন মান

touch() ফাংশনটি সফল হলে TRUE এবং ব্যর্থ হলে FALSE রিটার্ন করে।

উদাহরণ

<?php $myfile = "new.txt"; // মডিফিকেশন টাইম বর্তমান সিস্টেম টাইমে পরিবর্তন if (touch($myfile)) { echo ("The modification time of $myfile set to current time."); } else { echo ("The modification time of $myfile can't be updated."); } ?>

আউটপুট

The modification time of new.txt set to current time.

উদাহরণ

আরেকটি উদাহরণ দেখি।

<?php $myfile = "new.txt"; $set_time = time() - 28800; // মডিফিকেশন টাইম পরিবর্তন if (touch($myfile, $set_time)) { echo ("The modification time of $myfile updated to 8 hrs in the past."); } else { echo ("The modification time of $myfile can't be updated."); } ?>

আউটপুট

The modification time of new.txt updated to 8 hrs in the past.
  1. PHP-এ date_create() ফাংশন

  2. PHP-তে filemtime() ফাংশন

  3. PHP-তে filectime() ফাংশন

  4. PHP-তে fileatime() ফাংশন