PHP clearstatcache() 함수
❮ PHP 파일 시스템 참조예시
파일 크기를 출력하고, 파일을 자르고, 캐시를 지운 다음 파일 크기를 다시 출력합니다.
<?php
//output filesize
echo filesize("test.txt");
echo "<br />";
$file = fopen("test.txt", "a+");
// truncate file
ftruncate($file,100);
fclose($file);
//Clear cache and check filesize again
clearstatcache();
echo filesize("test.txt");
?>
위 코드의 출력은 다음과 같을 수 있습니다.
792
100
정의 및 사용
clearstatcache() 함수는 파일 상태 캐시를 지웁니다.
PHP는 성능 향상을 위해 일부 기능에 대한 데이터를 캐시합니다. 스크립트에서 파일을 여러 번 검사해야 하는 경우 올바른 결과를 얻기 위해 캐싱을 피하고 싶을 것입니다. 이렇게 하려면 clearstatcache() 함수를 사용합니다.
통사론
clearstatcache(clear_realpath_cache, filename)
매개변수 값
Parameter | Description |
---|---|
clear_realpath_cache | Optional. Indicates whether to clear the realpath cache or not. Default is FALSE, which indicates not to clear realpath cache |
filename | Optional. Specifies a filename, and clears the realpath and cache for that file only |
팁 및 참고 사항
팁: 캐싱 중인 함수:
- 통계()
- lstat()
- 파일이 존재()
- is_writable()
- is_readable()
- is_executable()
- is_file()
- is_dir()
- is_link()
- 파일 시간()
- 파일타임()
- 파일 시간()
- 파일 노드()
- 파일 그룹()
- 파일 소유자()
- 파일 크기()
- 파일 형식()
- 파일펌()
기술적 세부 사항
반환 값: | 아무것도 |
---|---|
PHP 버전: | 4.0+ |
PHP 변경 로그: | PHP 5.3 - 두 개의 선택적 매개변수가 추가됨: clear_realpath_cahe 및 filename |
❮ PHP 파일 시스템 참조