touch လုပ်ဆောင်ချက်
touch လုပ်ဆောင်ချက်သည် ဖိုင်၏ နောက်ဆုံးဝင်ရောက်ကြည့်ရှုချိန်နှင့် ပြုပြင်ချိန်ကို ပြောင်းလဲရန် ခွင့်ပြုပေးသည်။ သတ်မှတ်ထားသောဖိုင်မရှိပါက touch က ၎င်းကို ဖန်တီးပေးနိုင်သည် (ပုံသေအားဖြင့်)။ အချိန်ကို ထုတ်ဖော်သတ်မှတ်နိုင်ပြီး (သို့မဟုတ်) လက်ရှိအချိန်ကို အသုံးပြုနိုင်သည်။
ဝါကျဖွဲ့စည်းပုံ
touch(string $filename, int $time = null, int $atime = null): bool
ဥပမာ
လက်ရှိအချိန်ဖြင့် ဖိုင်အသစ်ဖန်တီးခြင်း:
<?php
$file = 'newfile.txt';
if (touch($file)) {
echo "ဖိုင် $file ကို ဖန်တီးပြီးပါပြီ";
}
?>
ကုဒ်အလုပ်လုပ်ဆောင်မှု၏ရလဒ်:
"ဖိုင် newfile.txt ကို ဖန်တီးပြီးပါပြီ"
ဥပမာ
ရှိပြီးသားဖိုင်၏အချိန်ကိုပြောင်းလဲခြင်း:
<?php
$file = 'existing.txt';
$time = strtotime('2023-01-01 12:00:00');
if (touch($file, $time)) {
echo "ဖိုင် $file ၏ အချိန်ကို ပြောင်းလဲပြီးပါပြီ";
}
?>
ကုဒ်အလုပ်လုပ်ဆောင်မှု၏ရလဒ်:
"ဖိုင် existing.txt ၏ အချိန်ကို ပြောင်းလဲပြီးပါပြီ"
ဥပမာ
ဝင်ရောက်ကြည့်ရှုချိန်နှင့် ပြုပြင်ချိန်ကို သီးသန့်ပြောင်းလဲခြင်း:
<?php
$file = 'test.txt';
$mtime = strtotime('2023-01-01 12:00:00');
$atime = strtotime('2023-01-02 12:00:00');
if (touch($file, $mtime, $atime)) {
echo "ဖိုင်၏ အချိန်တံဆိပ်များ မွမ်းမံပြီးပါပြီ";
}
?>