realpath_cache_get() 函數是 PHP 中的內置函數,用於檢索真實路徑緩存的當前內容。 PHP 使用真實路徑緩存來存儲將文件路徑映射到文件係統上的真實或規範路徑的結果。
用法:
realpath_cache_get(): array
Parameters: 該函數不接受任何參數。
返回值: realpath_cache_get()PHP 中的函數返回一個數組,其中包含有關真實路徑緩存當前內容的信息。數組中的每個條目對應一個緩存的真實路徑,並包含以下信息:
- filename:用於生成緩存真實路徑的路徑。
- realpath:文件係統上與緩存路徑對應的真實或規範路徑。
- expires:緩存的真實路徑將過期並從緩存中刪除的時間戳。
示例 1:下麵的程序演示了realpath_cache_get()函數。
PHP
<?php
$cache = realpath_cache_get();
print_r($cache);
?>
輸出:
Array ( [/home/dachman/Desktop] => Array ( [key] => 9.8987350635605E+18 [is_dir] => 1 [realpath] => /home/dachman/Desktop [expires] => 1680790990 ) [/home/dachman/Desktop/Articles/GFG/Method/index.php] => Array ( [key] => 1.1713322467E+19 [is_dir] => [realpath] => /home/dachman/Desktop/Articles/GFG/Method/index.php [expires] => 1680790990 ) [/home] => Array ( [key] => 4353355791257440477 [is_dir] => 1 [realpath] => /home [expires] => 1680790990 ) [/home/dachman/Desktop/Articles/GFG] => Array ( [key] => 1.7522950215249E+19 [is_dir] => 1 [realpath] => /home/dachman/Desktop/Articles/GFG [expires] => 1680790990 ) [/home/dachman/Desktop/Articles] => Array ( [key] => 1.4472601227808E+19 [is_dir] => 1 [realpath] => /home/dachman/Desktop/Articles [expires] => 1680790990 ) [/home/dachman/Desktop/Articles/GFG/Method] => Array ( [key] => 1554988915540397794 [is_dir] => 1 [realpath] => /home/dachman/Desktop/Articles/GFG/Method [expires] => 1680790990 ) [/home/dachman] => Array ( [key] => 1.4619779138232E+19 [is_dir] => 1 [realpath] => /home/dachman [expires] => 1680790990 ) )
示例 2:下麵的程序演示了realpath_cache_get()函數。
PHP
<?php
$cache = realpath_cache_get();
foreach ($cache as $path => $info) {
echo "Path: $path\n";
echo "Realpath: {$info["realpath"]}\n";
echo "Expires: " . date("Y-m-d H:i:s",
$info["expires"]) . "\n\n";
}
?>
輸出:
Path: /home/dachman/Desktop Realpath: /home/dachman/Desktop Expires: 2023-04-06 14:27:00 Path: /home/dachman/Desktop/Articles/GFG/Method/index.php Realpath: /home/dachman/Desktop/Articles/GFG/Method/index.php Expires: 2023-04-06 14:27:00 Path: /home Realpath: /home Expires: 2023-04-06 14:27:00 Path: /home/dachman/Desktop/Articles/GFG Realpath: /home/dachman/Desktop/Articles/GFG Expires: 2023-04-06 14:27:00 Path: /home/dachman/Desktop/Articles Realpath: /home/dachman/Desktop/Articles Expires: 2023-04-06 14:27:00 Path: /home/dachman/Desktop/Articles/GFG/Method Realpath: /home/dachman/Desktop/Articles/GFG/Method Expires: 2023-04-06 14:27:00 Path: /home/dachman Realpath: /home/dachman Expires: 2023-04-06 14:27:00
注意:輸出是特定於係統的,並且根據係統的不同而有所不同。
參考:https://www.php.net/manual/en/function.realpath-cache-get.php
相關用法
- PHP realpath_cache_get()用法及代碼示例
- PHP realpath_cache_size()用法及代碼示例
- PHP realpath( )用法及代碼示例
- PHP readfile()用法及代碼示例
- PHP readdir()用法及代碼示例
- PHP read_exif_data()用法及代碼示例
- PHP readline_add_history()用法及代碼示例
- PHP readline()用法及代碼示例
- PHP rename()用法及代碼示例
- PHP rewind()用法及代碼示例
- PHP restore_error_handler()用法及代碼示例
- PHP restore_exception_handler()用法及代碼示例
- PHP reset()用法及代碼示例
- PHP rewinddir()用法及代碼示例
- PHP require()和include()的區別用法及代碼示例
- PHP require()和require_once()的區別用法及代碼示例
- PHP round()用法及代碼示例
- PHP rmdir()用法及代碼示例
- PHP rad2deg()用法及代碼示例
- PHP rand()用法及代碼示例
- PHP random_int()用法及代碼示例
- PHP range()用法及代碼示例
- PHP rawurldecode()用法及代碼示例
- PHP rawurlencode()用法及代碼示例
- PHP rsort()用法及代碼示例
注:本文由純淨天空篩選整理自neeraj3304大神的英文原創作品 PHP realpath_cache_get() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。