note 8630 deleted from function.dirname by irc-html

From: Date: Thu, 03 Jan 2002 02:15:21 +0000
Subject: note 8630 deleted from function.dirname by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-24329@lists.php.net to get a copy of this message
if you are confused by the results of using dirname() or basename, see http://www.helpnet.com.au/php/ There are a few too many examples to copy in to here. basename() selects what it thinks is a file name including simple directory names. dirname() selects what it thinks is a path including simple file names. You need to either account for the exceptions or perform your own split of the file reference/url. Accounting for the exceptions could include using one of the file functions to check if the result is a valid directory. As dirname() is likely to drop a simple directory name and let it appear in basename(), you may have to check basename first to find if basename() has a directory name then add that back to the result in dirname(). The pages of examples show you what happens and what to do if you expect simple names to be page names. That is what happens on most of the sites I fix. Someone supplies a page name without a directory name. basename() works and dirname() duplicates basename(). It is different on some site. People and programs supply directory names one minute then page names another time. Both end up in both dirname() and basename(). I have to confirm the meaning via a file function.

« previous php.notes (#24329) next »