php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46034 php cli -d include_path only accepts first parameter
Submitted: 2008-09-09 18:08 UTC Modified: 2008-10-24 15:43 UTC
From: php at ryank dot net Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 5.2.6 OS: WinXP
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: php at ryank dot net
New email:
PHP Version: OS:

 

 [2008-09-09 18:08 UTC] php at ryank dot net
Description:
------------
When using the -d flag in php-cli on the include_path directive, only the first parameter is assigned to include_path.

C:\>php -v

PHP 5.2.6 (cli) (built: May  2 2008 18:02:07)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
    with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans

Reproduce code:
---------------
C:\>php -r "print ini_get('include_path');" -d include
_path=c:\test1.ini;c:\test2.ini

Expected result:
----------------
c:\test1.ini;c:\test2.ini

Actual result:
--------------
c:\test1.ini

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-09 18:14 UTC] php at ryank dot net
This apparently works fine though...

C:\>php -r "print ini_get('include_path');" -d include
_path=.;c:\test1;c:\test2

.;c:\test1;c:\test2
 [2008-09-09 18:41 UTC] lbarnaud@php.net
You may enclose the value with ' or " like in php.ini
 [2008-09-10 16:21 UTC] php at ryank dot net
Double quotes do not appear to help:

C:\>php -r "print ini_get('include_path');" 
-d include_path=".;:\test1;c:\test2"
.;c:\test1;c:\test2

C:\>php -r "print ini_get('include_path');" 
-d include_path="c:\test1;c:\test2"
c:\test1

Single quotes become part of the directive:

C:\>php -r "print ini_get('include_path');" -d include_path='c:\test1;c:\test2'
'c:\test1
 [2008-09-10 20:15 UTC] jani@php.net
You need to enclose all of it in quotes:

# php -d "include_path=some;path;here" ..
 [2008-09-11 14:24 UTC] php at ryank dot net
Still having issues:

C:\>php -r "print ini_get('include_path');" -d "include_path=c:\testing1;c:\testing2"
c:\testing1

C:\>php -r "print ini_get('include_path');" -d "include_path=.;c:\testing1;c:\testing2"

.;c:\testing1;c:\testing2
 [2008-09-11 14:39 UTC] lbarnaud@php.net
The quotes are "used" by your shell, just like those around the php
code.

-d "include_path=foo;bar" is passed as -d include_path=foo;bar to php.

You must enclose the quotes themselves, for example by using single
quotes: -d 'include_path="foo;bar"' (works on "classic" shells, but I
don't know how windows handles this)
 [2008-10-03 06:36 UTC] kalle@php.net
Works fine for me:
C:\php\src\Release_TS>php -v
PHP 5.3.0alpha3-dev (cli) (built: Oct  2 2008 21:44:41)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2008 Zend Technologies

C:\php\src\Release_TS>php -r "print ini_get('include_path');" -d "include_path='
C:\test1.ini;C:\test2.ini'"
C:\test1.ini;C:\test2.ini

The Windows shell only likes the double quote sign, so therefore "include_path='xxxx'" will work. but not 'include_path="xxxx"' (Will cause a alert saying 'Invalid configuration directive')
 [2008-10-24 15:43 UTC] jani@php.net
There's no bug here.
 [2011-04-06 03:37 UTC] jimb at connectedsw dot com
The bug is that 5.2 does not understand the use of apostrophes for quoting. This was fixed in 5.3. Test case #5 below shows a workaround for 5.2.

The problem reported by ryank is not a bug because his quoting was wrong and so the semicolon was being interpreted as a statement separator. Ryank could not use the quoting solutions recommended by the others because the apostrophe didn't work for quoting in 5.2. Since ryank used PHP 5.2 and kalle used 5.3, they were seeing different results.

To test this bug, I created a file named "test.php" and put the file in C:\ftp.

Test case #1: This works in 5.2 and 5.3.
php -r "print ini_get('include_path');require_once('test.php');" -d "include_path=C:\ftp"

Test case #2: This fails in 5.2 and 5.3, but that's correct because the semicolon is a command separator:
php -r "print ini_get('include_path');require_once('test.php');" -d "include_path=C:\tmp;C:\ftp"

Test case #3: This fails in 5.2 and works in 5.3. This shows that 5.2 can't handle single quotes:
php -r "print ini_get('include_path');require_once('test.php');" -d "include_path='C:\ftp'"

Test case #4: This also fails in 5.2 and works in 5.3. However, the reason is because 5.2 can't handle the single quotes.
php -r "print ini_get('include_path');require_once('test.php');" -d "include_path='C:\tmp;C:\ftp'"

Test case #5: This works in both 5.2 and 5.3. It works around the 5.2 limitation.
php -r "print ini_get('include_path');require_once('test.php');" -d "include_path=\"C:\tmp;C:\ftp\""
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 06:01:31 2024 UTC