note 115307 added to function.dirname
| From: | alexcaigel at yahoo dot com | Date: | Thu, 03 Jul 2014 07:54:26 +0000 |
| Subject: | note 115307 added to function.dirname | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199814@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.
<?php
$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 for http://coralclub24.com/
href='<?=$base_url?>/myscript.php'
----
Server IP: 72.52.91.14
Probable Submitter: 46.250.22.71
----
Manual Page -- http://php.net/manual/en/function.dirname.php
Edit -- https://master.php.net/note/edit/115307
Del: integrated -- https://master.php.net/note/delete/115307/integrated
Del: useless -- https://master.php.net/note/delete/115307/useless
Del: bad code -- https://master.php.net/note/delete/115307/bad+code
Del: spam -- https://master.php.net/note/delete/115307/spam
Del: non-english -- https://master.php.net/note/delete/115307/non-english
Del: in docs -- https://master.php.net/note/delete/115307/in+docs
Del: other reasons-- https://master.php.net/note/delete/115307
Reject -- https://master.php.net/note/reject/115307
Search -- https://master.php.net/manage/user-notes.php