php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #18657 CLI version: scriptname is only available through argv
Submitted: 2002-07-30 15:59 UTC Modified: 2002-08-10 18:47 UTC
From: cmv@php.net Assigned: helly (profile)
Status: Closed Package: Feature/Change Request
PHP Version: 4.2.2 OS: Linux 2.4
Private report: No CVE-ID: None
 [2002-07-30 15:59 UTC] cmv@php.net
With the CLI version, the only way to access the script name is through:

    $_SERVER['argv'][0]

In 4.2.2, $_SERVER['PHP_SELF'] is set, but empty.  In 4.3.0-dev, it's not even set.

I don't know which of $_SERVER['SCRIPT_NAME'] or $_SERVER['PHP_SELF'] would be more appropriate, but I think setting either of those to the script name would be more intuitive, and might make porting web-based scripts to CLI-based scripts easier.

- Colin

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-30 16:01 UTC] rasmus@php.net
Would be a bit odd to have any $_SERVER variables in the cli version as there is no server.
 [2002-08-03 09:21 UTC] helly@php.net
But it would make sense AND the incase of CLI why not treat SHELL as SERVER?
 [2002-08-10 18:47 UTC] helly@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.

All file relevant variables are now available by $_SERVER.

PHP_SELF filename or '-' for stdin
SCRIPT_NAME filename or '-' for stdin
SCRIPT_FILENAME filename or '' for stdin
PATH_TRANSLATED or '' for stdin
DOCUMENT_ROOT allways ''

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 03:01:28 2024 UTC