Re: Get filename in php command line

From: Date: Tue, 17 Jul 2001 15:29:03 +0000
Subject: Re: Get filename in php command line
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58281@lists.php.net to get a copy of this message
$PHP_SELF returns the filename with the full path. from there, you can use split to split the string wherever a / occurs, then call count, to get the total number of values in the array, decrememnt the count by 1 (Arrays begin at 0) then, set a variable to store just the filename, like so: $fullpath = split('/',$PHP_SELF); $c = count($fullpath); $c--; $filename = $fullpath[$c]; There may be a better way to do it, but this works for me, and it's only 4 lines. :) JB ----- Original Message ----- From: "Reuben D Budiardja" <reubendb@goshen.edu> To: <php-general@lists.php.net> Sent: Tuesday, July 17, 2001 7:48 AM Subject: [PHP] Get filename in php command line Hello, How do I get the filename or script name if I run it in php comamnd line? For example, if I run this bash$ php test.php I want to get something inside test.php that tells me the filename is test.php, but *without* the actual path. Thanks Reuben D. Budiardja -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#58281) next »