Re: file knowing its own directory
| From: | Red Wingate | Date: | Wed, 09 Jun 2004 22:48:36 +0000 |
| Subject: | Re: file knowing its own directory | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-187996@lists.php.net to get a copy of this message | ||
the magic constant __FILE__ will give you the absolut filesystem location of the file it is called. Eg:
/home/www/tests/foo.php ->
<?php
echo __FILE__ ;
?>
will print: '/home/www/tests/foo.php';
to retrieve the path only you could do:
/home/www/tests/foo.php ->
<?php
echo str_replace( basename ( __FILE__ ) , '' , __FILE__ );
?>
will print: '/home/www/tests/';
hope this helps :-)
Dennis Gearon wrote:
please CC me 'cause I am on digest
the scenario:
three files:
.htaccess
has line saying "php_prepend 'true_filesystem_location_php_prepend_file' "
prepend.php (aforementioned prepend file)
has line saying "include file_a.php"
file_a.php
has line saying"$my_true_file_system_location = I_NEED_A_FUNCTION_HERE;"
So, what do I replace I_NEED_A_FUNCTION_HERE with?