php.net |  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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jirapat at gmail dot com
New email:
PHP Version: OS:

 

 [2015-11-24 03:26 UTC] jirapat at gmail dot com
Description:
------------
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
int(2)
var_dump argv
array(2) {
  [0]=>
  string(7) "arg.php"
  [1]=>
  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
int(1)
var_dump argv
array(1) {
  [0]=>
  string(7) "arg.php"
}


Test script:
---------------
<?
echo "var_dump argc\n";
var_dump($argc);

echo "var_dump argv\n";
var_dump($argv);

?>

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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-24 04:07 UTC] laruence@php.net
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] laruence@php.net
-Assigned To: +Assigned To: ab
 [2015-11-24 06:41 UTC] laruence@php.net
@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] ab@php.net
I've just tried and couldn't repro the bug just with "php file.php". So confirmed it's nothing with PHP.

Thanks.
 [2015-12-17 10:53 UTC] cmb@php.net
-Status: Closed +Status: Not a bug -Package: PHP Language Specification +Package: Scripting Engine problem
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC