Seems that $PHP_SELF is not defined when it's run from the command line.

Reuben D. Budiardja

On Tuesday 17 July 2001 10:29 am, Jason Bell wrote:
> $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" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to