|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-06-16 10:59 UTC] ralph at deboom dot biz
Description: ------------ Quoted from: http://bugs.php.net/bug.php?id=841 [21 Dec 1998 2:06pm UTC] rasmus The correct operations of these functions should be... dirname returns everything PRIOR to the last / or \ in the path. basename returns everything AFTER the last / or \ in the path. ---------------------------------------------------------------- There are several more people on www.php.net/dirname comments who are confused by this aswell. Reproduce code: --------------- <?php echo dirname('/dir1/dir2/dir3/'); Expected result: ---------------- /dir1/dir2/dir3 Or/And update the docs: www.php.net/dirname Actual result: -------------- /dir1/dir2 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 19 16:00:01 2025 UTC |
Ok super! :) ------------------------------- I got a workaround for the people who are using the older versions: <?php function __dirname($dirname) { if (substr($dirname, -1, 1) == '/' || substr($dirname, -1, 1) == '\\') { $dirname = dirname($dirname.'.'); } else { $dirname = dirname($dirname); } }~_~ Oops, forgot the return $dirname: ------------------------- <?php function __dirname($dirname) { if (substr($dirname, -1, 1) == '/' || substr($dirname, -1, 1) == '\\') { $dirname = dirname($dirname.'.'); } else { $dirname = dirname($dirname); } return $dirname; }