Re: PHP equivalent to Perl $0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, January 31, 2007 5:59 pm, Richard Luckhurst wrote:
> In Perl there is the predefined $0 which contains the name of the file
> containing the Perl script being executed. Is there an equivalent in
> PHP?

$_SERVER['PHP_SELF']

> I am working on converting a Listener script from Perl to PHP and at
> one point
> when the script forks it has a line
>
> $0 = "Listener is accepting connections on Port $port";
>
> When this Perl script is running and I do a ps I see a process ID with
> the
> program being
>
> Listener is accepting connections on Port $port
>
> instead of the actual name of the Perl script.
>
> Is such a thing possible in PHP? If so how? I have been Google
> searching for a
> while and can not see one way or the other if it is possible.

I have no idea if you can cram some whack value into that and then ps
would show that instead of the path...  I doubt it.

And, frankly, why would you want to do that?  It only sows confusion
in ps output. :-)

Unless the whole rest of the application is relying on this sugar
candy feature (scary idea) I'd say just skip that line.

If PHP does have such a feature, it would probably be grouped with the
functions here:
http://php.net/manual/en/ref.info.php

I'm not seeing anything there.

You might be able to hack something with http://php.net/exec and the
http://php.net/getmypid to do whatever it is that Perl does when you
assign a value to $0 (shudder).

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux