|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #29658 #!php with paramters is broken
Submitted: 2004-08-13 19:04 UTC Modified: 2004-08-14 12:15 UTC
From: xuefer at 21cn dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.3.8 OS: xp+cygwin &linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: xuefer at 21cn dot com
New email:
PHP Version: OS:


 [2004-08-13 19:04 UTC] xuefer at 21cn dot com
touch php.ini

./test | grep php.ini

-i paramter works
but -c not

seems those spaces is not convert to '\0'


    while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0))!=-1) {
        switch (c) {
        case 'c':
            cli_sapi_module.php_ini_path_override = strdup(php_optarg);
printf("%d %d '%s'\n", (int) php_optarg[0], strlen(php_opt_arg), php_optarg);
        case 'n':
            cli_sapi_module.php_ini_ignore = 1;

got "32 2 ' .'"

seems a problem of the shell

if -c is ok to be left broken.
-i shouldn't be working too

but allowing options in #! is very useful

Reproduce code:
#!/usr/bin/php -i -c .
// empty file

Expected result:
Configuration File (php.ini) Path => /etc/php.ini

Actual result:
Configuration File (php.ini) Path => ./php.ini


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-13 19:21 UTC]
#! is a unixy thing that is not supported on windows.
Additionally, most OS's don't support more than a single parameter there.
Not a PHP bug.
 [2004-08-14 05:01 UTC] xuefer at 21cn dot com
changed to feature request
updated os

how about:
#!/usr/bin/php -p "........"
p means parameters (or -o options)
and the string after it is parsed as command line options as shell do
 [2004-08-14 12:15 UTC]
Not a PHP problem.
Nothing we can do about it.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue May 17 08:05:45 2022 UTC