Posted by Pr0 N00b on 06/24/05 12:27
Kees Boer schreef:
> Hi, I was wondering if there was a way for a PHP file to retrieve the name
> of what it was running. I.e. If I'm running piercebrosnan.php, the PHP file
> would be able to retrieve the name piercebrosnan as a variable.
>
> I hope that makes sense.
>
> Kees
>
> P.S. If anyone is wondering what I'm doing with all of this information. I'm
> working on a website called www.positive-entertainment.com which has all my
> reviews and interviews with celebrities on it.
The big difference between $_SERVER['PHP_SELF'] and __FILE__ is that
__FILE__ holds the name of the currently running php file, and
$_SERVER['PHP_SELF'] is the name of the file which called the other files
Example:
index.php
<?php
echo $_SERVER['PHP_SELF'] // will output /index.php
echo __FILE__ // will output /index.php
define('INDEX_LOADED', true);
include('test.php');
?>
test.php
<?php
if (!defined('INDEX_LOADED')) exit;
echo $_SERVER['PHP_SELF'] // will output /index.php
echo __FILE__ // will output /test.php
?>
[Back to original message]
|