|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-06-22 14:16 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2021-06-22 14:16 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 14:00:02 2025 UTC |
Description: ------------ This is a very strange question. It looks realpath returns false, but it's not. This happens in the phar file. Test script: --------------- <?php /** * realpath not work in phar pack file */ $paths = [ 'phar://phar_test.phar/hello', 'phar://phar_test.phar/hello/a.php', ]; function let_it_work(string $path) { $realPath = realpath($path); if ($realPath !== false) { $path = $realPath; } return $path; } function show_false(string $path) { return realpath($path); } foreach ($paths as $path) { var_dump(file_exists($path)); // return true var_dump(realpath($path)); // return false var_dump(let_it_work($path)); // it's work var_dump(show_false($path)); // return false } function entry(DirectoryIterator $dir = null) { if ($dir === null) $dir = new DirectoryIterator(__DIR__); foreach ($dir as $item) { $path = $item->getPathname(); var_dump(file_exists($path)); // true var_dump($item->getRealPath()); // false } } entry(new DirectoryIterator('phar://phar_test.phar'));