Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> PHP

ฟังก์ชัน clearstatcache() ใน PHP

ฟังก์ชัน clearstatcache() ใช้ล้างแคชสถานะไฟล์ (file status cache)

PHP จะแคชข้อมูลที่คืนโดยฟังก์ชันต่อไปนี้:

  • stat()
  • lstat()
  • file_exists()
  • is_writable()
  • is_readable()
  • is_executable()
  • is_file()
  • is_dir()
  • filegroup()
  • fileowner()
  • filesize()
  • filetype()
  • fileperms()

ทำเช่นนี้เพื่อเพิ่มประสิทธิภาพ (Performance)

Syntax

void clearstatcache()

Parameters

  • ไม่มีพารามิเตอร์

Return

ไม่มีค่าคืนจากฟังก์ชัน clearstatcache()

ตัวอย่าง

ตัวอย่างต่อไปนี้ตรวจสอบไฟล์ "tmp.txt" และล้างแคช

<?php 
   $file = fopen("tmp.txt", "a+"); 
   // Clear cache 
   clearstatcache(); 
   echo "Cache cleared!"; 
?>

ผลลัพธ์

Cache cleared!