Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- James Pittman
March 29, 2005, 8:11 pm
rate this thread
Re: Getting script pathname in a script run from the command line
James Pittman napisa│:
Do you mean the filename of the script, like
Then you should use the __FILE__ superconstant. It holds the filename of
the currently executing script.
BUT that means, that if you have:
# in test_script.php:
echo 'First echo: ' . __FILE__ . '<BR>';
# in host_script.php:
echo 'Second echo: ' . __FILE__;
you will get:
First echo: (...)/test_script.php<BR>
Second echo: (...)/host_script.php
Chech the www.php.net page for more info on __FILE__ constant, you will
get a lot of useful hints there. AFAIR they have something in the "See
also:" section, that will give you always the "host_script.php".
Nope, it won't work. These are only set in a webserver enviroment; forget
about them in a command-line parser.