Example 1 — Check That the Cache Has Entries
Call realpath() once so PHP stores a path, then read the cache.
<?php
realpath(__DIR__);
$cache = realpath_cache_get();
echo count($cache) > 0 ? 'The cache has entries' : 'The cache is empty', PHP_EOL; How It Works
- realpath() resolves the current folder, and PHP saves the result in its cache.
- realpath_cache_get() returns every cached path as an array.
- count() tells us how many entries there are.
- Because we just resolved a path, the cache is not empty.

