php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26206 argv and argc not defined
Submitted: 2003-11-11 12:52 UTC Modified: 2004-03-18 09:02 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: danielc at analysisandsolutions dot com Assigned:
Status: Closed Package: CGI/CLI related
PHP Version: 5CVS-2004-01-08 OS: Windows 2000
Private report: No CVE-ID: None
 [2003-11-11 12:52 UTC] danielc at analysisandsolutions dot com
Description:
------------
$_SERVER['argv'] and $_SERVER['argc'] aren't created.

php.ini and phpinfo() show register_argc_argv as being On.

Behavior is the same via CLI or CGI binaries.

Substituted a known good php.ini file to see ensure the file was getting parsed.  Same results.

Everything worked fine under 500b2-dev--php5-win32-200310010230

Problem began when upgraded to 500b2-dev--php5-win32-200311040330

Persists in the current CVS snapshot
500b3-dev--php5-win32-200311111530

Reproduce code:
---------------
#! c:/progra~1/php/cli/php
<?php
print_r($_SERVER['argv']);
?>

now execute test script...
./t.php fjiao

Expected result:
----------------
Array
(
    [0] => ./t.php
    [1] => fjiao
)

Actual result:
--------------
Notice: Undefined index:  argv in d:\t.php on line 3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-27 19:03 UTC] iliaa@php.net
Try following:

php -n -r " var_dump($_SERVER['argv']); " 1 2 3
 [2003-11-27 19:24 UTC] danielc at analysisandsolutions dot com
Your test of ignoring the php.ini file via the -n flag gets it to work as expected.

FYI...

C:\PROGRA~1\php\cli>php -i | grep argv
register_argc_argv => On => On

C:\PROGRA~1\php\cli>php -n -i | grep argv
register_argc_argv => On => On
_SERVER["argv"] => Array

C:\PROGRA~1\php\cli>php -v
PHP 5.0.0b3-dev (cli) (built: Nov 26 2003 04:10:19)
 [2003-11-29 00:15 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

I can not reproduce this on windows using latest CVS snapshot.

 [2003-12-01 00:35 UTC] danielc at analysisandsolutions dot com
No luck with the new snapshot.

Downloaded php5-win32-200312010330.zip, copied php.ini-recommended to php.ini, turned register_argc_argv = On, ran the following...

C:\PROGRA~1\php\cli>php -i | grep argv
register_argc_argv => On => On

C:\PROGRA~1\php\cli>php -r " var_dump($_SERVER['argv']); " 1 2 3
PHP Notice:  Undefined index:  argv in Command line code on line 1
NULL
 [2003-12-01 03:25 UTC] sniper@php.net
And you're absolutely sure you don't have ANY old PHP related dlls in your system before you installed the snapshot?
(delete all php4ts.dll files..)

 [2003-12-01 12:04 UTC] danielc at analysisandsolutions dot com
100% certain.

New PHP installs on this system are by moving the entirety of the old install aside, extracting the contents of a new snapshot .zip file then copying the exact files/structure over to the php directory.  The system finds the DLLS via the %path%, in which "C:\PROGRA~1\Php;C:\PROGRA~1\Php\dlls;" are the first two entries.

The PHP DLL's have never been copied to any other location on this computer.
 [2003-12-01 13:31 UTC] sniper@php.net
Well, I can't reproduce this with either CLI or CGI, using either php.ini-dist or php.ini-recommended. So there's something wrong with your system, not PHP.

 [2003-12-01 13:57 UTC] danielc at analysisandsolutions dot com
Everything worked fine until I switched from php5-win32-200310010230.zip to php5-win32-200311040330.zip

I will track down exactly which snapshot in this time period started causing the problem.  Then someone can examine the changes made in order to isolate the problem.

Please inform me where I can find old snapshots to do this.
http://snaps.php.net/win32/ only has the most recent few.
 [2004-01-07 21:38 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

Please try the latest snapshot.

 [2004-01-08 13:14 UTC] danielc at analysisandsolutions dot com
No dice using php5-win32-200401081130
 [2004-01-17 14:17 UTC] danielc at analysisandsolutions dot com
Greg just posted on the internals list that he too noticed that $_SERVER['argv'] and $_SERVER['argc'] aren't set.

He also made a very interesting observation that $argv and $argc ARE set.


EXAMPLE SCRIPT argvtest.php:
<?php
var_dump($argv);
var_dump($_SERVER['argv']);
?>


INVOCATION:
C:\PROGRA~1\php>php argvtest.php 1 2


OUTPUT:
array(3) {
  [0]=>
  string(12) "argvtest.php"
  [1]=>
  string(1) "1"
  [2]=>
  string(1) "2"
}

Notice: Undefined index:  argv in C:\PROGRA~1\php\argvtest.php on line 3
NULL
 [2004-01-17 19:44 UTC] danielc at analysisandsolutions dot com
Here's a link to the discussion on the interals list back in October about these changes:
http://marc.theaimsgroup.com/?t=106509307300006&r=1&w=2

This is a link to the current discussion regarding the situation and how either I'm misunderstanding things or things may not be working as expected:
http://marc.theaimsgroup.com/?t=107436583100001&r=1&w=2
 [2004-01-27 13:19 UTC] danielc@php.net
In the current thread, Jani pointed out that this is related to bug 25724 -- http://bugs.php.net/bug.php?id=25724 -- which
says that when register_long_arrays is off, the superglobals are broken.

So, until that bug is fixed, turn register_long_arrays = On in php.ini to get $_SERVER['argv'] and $_SERVER['argc'] to work.
 [2004-02-16 23:48 UTC] sniper@php.net
duplicate status is deprecated.

 [2004-03-18 09:02 UTC] zeev@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC