note 28397 added to function.dirname

From: Date: Sat, 11 Jan 2003 18:43:37 +0000
Subject: note 28397 added to function.dirname
Groups: php.notes 
Request: Send a blank email to php-notes+get-42003@lists.php.net to get a copy of this message
dirname can be used to create self referencing web scripts with the following one liner. $base_url = str_replace($DOCUMENT_ROOT, "", dirname($PHP_SELF)); Using this method on a file such as: /home/mysite/public_html/wherever/whatever.php will return: /wherever Now $base_url can be used in your HTML to reference other scripts in the same directory. Example: href='<?=$base_url?>/myscript.php' -- http://www.php.net/manual/en/function.dirname.php http://master.php.net/manage/user-notes.php?action=edit+28397 http://master.php.net/manage/user-notes.php?action=delete+28397 http://master.php.net/manage/user-notes.php?action=reject+28397

« previous php.notes (#42003) next »