|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70964 $argc and $argv return wrong value
Submitted: 2015-11-24 03:26 UTC Modified: 2015-12-17 10:53 UTC
From: jirapat at gmail dot com Assigned: ab (profile)
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.0.0RC7 OS: Windows 10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: jirapat at gmail dot com
New email:
PHP Version: OS:


 [2015-11-24 03:26 UTC] jirapat at gmail dot com
in version 7.0.0RC7 it regist wrong $argc and $argv
$argc should be 1 (when no argument even run from php.exe)
$argv[1] should not be set.

in version 5.6.15 is not a problem (may be 7.0 RC3 is doing right too)

D:\dropbox>php -v
PHP 7.0.0RC7 (cli) (built: Nov 11 2015 12:29:58) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

D:\dropbox>php arg.php
var_dump argc
var_dump argv
array(2) {
  string(7) "arg.php"
  string(8) "arg.php0"

D:\dropbox>c:\php56\php -v
PHP 5.6.15 (cli) (built: Oct 29 2015 12:40:36)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

D:\dropbox>c:\php56\php arg.php
var_dump argc
var_dump argv
array(1) {
  string(7) "arg.php"

Test script:
echo "var_dump argc\n";

echo "var_dump argv\n";


Expected result:
$argc = 1 when no command line variable
$argv[1] should not be set.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-24 04:07 UTC]
I can not reproduce this
 [2015-11-24 05:25 UTC] jirapat at gmail dot com
I'm not sure are you running the same version and the same value like me ?

to reproduce this just simply run
php.exe arg.php

or may it can be confused by old dll ,  I just copy all the file after extract it to same directory of php and run like the command above
 [2015-11-24 06:41 UTC]
-Assigned To: +Assigned To: ab
 [2015-11-24 06:41 UTC]
@welting are you able to reproduce this on windows?
 [2015-11-24 08:47 UTC] jirapat at gmail dot com
-Status: Assigned +Status: Closed
 [2015-11-24 08:47 UTC] jirapat at gmail dot com
Sorry after I found my problem now 

The problem is from my fault on php.bat in my system path

the bat file is like this

@c:\php\php.exe  %1 %2 %3 %4 %5 %6 %7 %8 %9 %10

and windows 10 push the last argument with %10 (maximum variable of bat file is 9)
 [2015-11-25 14:21 UTC]
I've just tried and couldn't repro the bug just with "php file.php". So confirmed it's nothing with PHP.

 [2015-12-17 10:53 UTC]
-Status: Closed +Status: Not a bug -Package: PHP Language Specification +Package: Scripting Engine problem
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Nov 30 04:05:54 2022 UTC