|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-06-10 12:05 UTC] RQuadling at GMail dot com
[2016-06-10 12:09 UTC] rquadling@php.net
-Summary: Relative Drive:path incorrectly assumed to be
Drive:/path
+Summary: Relative Drive:path incorrectly assumed to be
Drive:\path
[2021-04-22 12:13 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 22 07:00:01 2025 UTC |
Description: ------------ If you use a relative path to a file from Windows command line, PHP interprets the supplied location as a root. The test script below requires a Windows setup with 2 drives (C and D). The script is a batch script that creates the test script and cleans up after itself. Whilst this is similar in some aspects to previously reported bugs related to realpath(), the issue is that the constants __FILE__ and __DIR__ are correct, thus making them useless. OOI, using the absolute path for the PHP script (C:\PHP56\PHP D:\ReaL\PaTH\BuG\TeSTBuG.php), produces the correct results. Test script: --------------- @ECHO OFF REM Make directories for testing. MD C:\Test\Real\PaTH\BuG MD D:\ReaL\PaTH\BuG REM Make test PHP script. ECHO ^<?php > D:\ReaL\PaTH\BuG\TeSTBuG.php ECHO var_export([PHP_VERSION, __FILE__, __DIR__, getcwd(), realpath(__FILE__), realpath(__DIR__), realpath(getcwd()), $argv]);>> D:\ReaL\PaTH\BuG\TeSTBuG.php REM Make sure drives are in their directories. CD /D D:\ReaL\PaTH\BuG CD /D C:\Test\Real\PaTH\BuG REM Call PHP using relative paths. C:\PHP56\PHP D:TeSTBuG.php REM Clean-up DEL D:\ReaL\PaTH\BuG\TeSTBuG.php CD /D D:\ CD /D C:\ RD C:\Test\Real\PaTH\BuG RD D:\ReaL\PaTH\BuG Expected result: ---------------- array ( 0 => '5.6.20', 1 => 'D:\\ReaL\\PaTH\\BuG\\TeSTBuG.php', 2 => 'D:\\ReaL\\PaTH\\BuG', 3 => 'C:\\Test\\Real\\PaTH\\BuG', 4 => D:\\ReaL\\PaTH\\BuG\\TeSTBuG.php, 5 => 'D:\\ReaL\\PaTH\\BuG', 6 => 'C:\\Test\\Real\\PaTH\\BuG', 7 => array ( 0 => 'D:TeSTBuG.php', ), ) Actual result: -------------- array ( 0 => '5.6.20', 1 => 'D:\\TeSTBuG.php', 2 => 'D:\\', 3 => 'C:\\Test\\Real\\PaTH\\BuG', 4 => false, 5 => 'D:\\', 6 => 'C:\\Test\\Real\\PaTH\\BuG', 7 => array ( 0 => 'D:TeSTBuG.php', ), )