[TYPO3-core] RFC: cli_dispatch.phpsh

Bernhard Kraft kraftb at kraftb.at
Wed Nov 29 13:35:30 CET 2006


Hi,


> Neither $_ENV['_'] nor $_SERVER['_'] is set on my server ("standard"
> SuSE Linux with PHP 4.3.8).

Whenever I want to get the filename of the current file in the filesystem
(The real location - meaning all symbolic links resolved) - i alwyays
use:

echo __FILE__;

:)

Most people don't know about the by default set constants:
__FILE__
__CLASS__
__LINE__
__FUNCTION__

they get set by default - it is also very nice to track down erros using
those constants.

Example script (test.php):
-----
#!/usr/bin/php
<?php
echo __FILE__.chr(10);
?>
-----

Output:
------------------
kraftb at osmium ~ $ ./test.php
/home/kraftb/test.php
kraftb at osmium ~ $ /home/kraftb/test.php
/home/kraftb/test.php
kraftb at osmium ~ $ cd ..
kraftb at osmium /home $ kraftb/test.php
/home/kraftb/test.php
kraftb at osmium /home $ symlink_to_kraftb/test.php
/home/kraftb/test.php
kraftb at osmium /home $
------------------


I cite from the PHP-manual:
(http://de.php.net/manual/en/language.constants.predefined.php)
-------------
__FILE__
  The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always 
contains an absolute path whereas in older versions it contained relative path under some circumstances.
--------




greets,
Bernhard
-- 
----------------------------------------------------------------------
"Freiheit ist immer auch die Freiheit des Andersdenkenden"
Rosa Luxemburg, 1871 - 1919
----------------------------------------------------------------------
[[ http://think-open.at | Open source company ]]


More information about the TYPO3-team-core mailing list