RE: [PHP] Get filename in php command line

From: Date: Tue, 17 Jul 2001 16:14:51 +0000
Subject: RE: [PHP] Get filename in php command line
Groups: php.general 
Request: Send a blank email to php-general+get-58291@lists.php.net to get a copy of this message
> I had that before. > OK, seems that my problem is not that simple. The thing is , > I have something > like this in my file test.php: > require('my_api.inc'); > echo "This is test.php3"; > Now, in my_api.inc, I want to know that I run test.php3, when I do > bash$ php test.php3 > and the filename is test.php3 . __FILE__ will give my my_api.inc > instead. I need it because my_api.inc do all sort of authenticating, > session, etc. __FILE__ will give you the name of the file that uses that constant. So, based on the above, I believe that you are using __FILE__ only in my_api.inc (which is pretty much what you said, I'm just looking for verification). What you can do instead is this: in "my_api.inc", have the following code: echo "Currently Running file is: "; echo ( $CurrentRunningFile ) ? $CurrentRunningFile : __FILE__; in test.php <? $CurrentRunningFile = __FILE__; include( "my_api.inc" ); echo "This is test.php3<br>\n"; ?> Define "$CurrentRunningFile" on line one of all your files. Or something along those lines... Chris

« previous php.general (#58291) next »