You are here: Re: The name of the PHP file « All PHP « IT news, forums, messages
Re: The name of the PHP file

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
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация