|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-02-07 02:49 UTC] aharvey@php.net
-Status: Open
+Status: Wont fix
[2012-02-07 02:49 UTC] aharvey@php.net
[2014-06-22 16:54 UTC] sun at unleashedmind dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 00:00:01 2025 UTC |
Description: ------------ On Windows, basename() works with \ or /. On Unix platforms it only works with /. Since / is technically wrong on Windows, it should let you be technically wrong on Unix using \. Why? I noticed this while working on a custom autoloader. I was trying to basename('namespace\class') and was getting back 'namespace\class' on Unix but only getting 'class' on Windows, and 'class' was the expected output. Since namespaces use a pseudo-filesystem structure I believe basename() (and probably dirname()) should be allowed to work properly on them regardless of the OS. "But you are't dealing with files so this is dumb" - when it comes to autoloading, namespaces and classes are dealing with files... so. Test script: --------------- <?php // on unix vs on windows spl_autoload_register(function($name){ var_dump(basename($name)); die(); }); new bob\ftw; ?> Expected result: ---------------- 'ftw' Actual result: -------------- 'bob\ftw' on unix.