Edit report at http://bugs.php.net/bug.php?id=33894&edit=1

 ID:                 33894
 Updated by:         [email protected]
 Reported by:        marcos dot neves at gmail dot com
 Summary:            __MAIN_FILE__ constant
-Status:             Open
+Status:             Bogus
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   any
 PHP Version:        5.1.0b3
 Block user comment: N
 Private report:     N

 New Comment:

PHP_SELF is the best we can offer. Mind that the "main" file is not
always clear - think aboutauto_prepend_file/auto_append_file etc.


Previous Comments:
------------------------------------------------------------------------
[2005-08-01 14:08:24] marcos dot neves at gmail dot com

$_SERVER['PHP_SELF'] hasn't the same value using php with apache and php
cli.

Run <? echo $_SERVER['PHP_SELF'] ?> in a browser and as command line,
you'll see the difference.



At browser works fine do the follow:



if(__FILE__ == $_SERVER['PHP_SELF']) {

}



but does not work with cli.



Tested with PHP 5.1.0b3 on windows XP

------------------------------------------------------------------------
[2005-08-01 13:28:51] [email protected]

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

We've PHP_SELF for this.

------------------------------------------------------------------------
[2005-07-27 23:27:50] marcos dot neves at gmail dot com

Description:
------------
Today we have __FILE__ constant, that has the string fileName of the
current scrit. Would be nice a constant __MAIN_FILE__, wich has the file
name of the first requested PHP file.

So would be possible to do things like this, without use of external
library, and is interesting to everyone:

Reproduce code:
---------------
<?



// class File



class Foo {}



if(__MAIN_FILE__ == __FILE__) {

// run some tests and usabe examples with Foo

}



?>



or used to include relative paths to an application, without define
constants



<?



// included script



require_once dirname(__MAIN_FILE__) . DIRECTORY_SEPARATOR .
"path/to/include/file.php";



?>



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=33894&edit=1

Reply via email to