note 54130 added to function.dirname
| From: | tobylewis at mac dot com | Date: | Fri, 24 Jun 2005 13:52:20 +0000 |
| Subject: | note 54130 added to function.dirname | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90896@lists.php.net to get a copy of this message | ||
Since the paths in the examples given only have two parts (e.g. "/etc/passwd") it is not
obvious whether dirname returns the single path element of the parent directory or whether it
returns the whole path up to and including the parent directory. From experimentation it appears to
be the latter.
e.g.
dirname('/usr/local/magic/bin');
returns '/usr/local/magic' and not just 'magic'
Also it is not immediately obvious that dirname effectively returns the parent directory of the last
item of the path regardless of whether the last item is a directory or a file. (i.e. one might
think that if the path given was a directory then dirname would return the entire original path
since that is a directory name.)
Further the presense of a directory separator at the end of the path does not necessarily indicate
that last item of the path is a directory, and so
dirname('/usr/local/magic/bin/'); #note final '/'
would return the same result as in my example above.
In short this seems to be more of a string manipulation function that strips off the last non-null
file or directory element off of a path string.
----
Manual Page -- http://www.php.net/manual/en/function.dirname.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54130
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54130&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54130&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54130&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54130&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54130&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54130&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54130&report=yes
Search -- http://master.php.net/manage/user-notes.php