[PHP-DEV] PHP 4.0 Bug #5076 Updated: command line php interpreter and command line arguments From: stas <email protected>
Date: 10/31/00

ID: 5076
Updated by: stas
Reported By: flebarbe <email protected>
Status: Closed
Bug Type: *General Issues
Assigned To:
Comments:

Fixed in CVS

Previous Comments:
---------------------------------------------------------------------------

[2000-09-04 22:09:27] sniper <email protected>
Just tested this with latest CVS and seems like
the -d include_path=.:/path/to/foo is totally ignored
and only setting include_path in php.ini works.

--Jani

---------------------------------------------------------------------------

[2000-06-16 11:23:43] flebarbe <email protected>
php built as cgi :
./configure --prefix=/usr
--with-config-file-path=/etc/php
--enable-force-cgi-redirect
--without-pcre-regex
--enable-debug=no
--enable-safe-mode

$grep include_path /etc/php/php.ini
include_path = .
$ls include/me.inc
include/me.inc
$php -q -d include_path=.:include
<?php
include ('me.inc');
?>
^D
<b>Warning</b>: Failed opening 'me.inc' for inclusion (include_path='.') in <b>-</b> on line <b>2</b><br>

I had a look at the code in sapi/cgi/cgi_main.c,
php_ini.c as well as configuration-parser.y.
configuration-parser.y and cgi_main.c. They all call
php_ini.c/php_alter_ini_entry. It's called a first
time from configuration-parser with '.' coming
from /etc/php/php.ini and then called from
the command-line "analyser" (/sapi/cgi/cgi_main.c)
Because the value is already set, the first test in
alter_ini_entry fails and returns (php_ini.c:143) :
if (zend_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==FAILURE) {
                return FAILURE;
        }

I use the cgi version in command line for some cron scripts
related to a whole web-based application, that's the reason
why I need this.

The workaround I've found ?
Have php.ini in the directory the scripts are in with
the variables correctly set in it. :-(((

BTW, have a look at this (shell related) one :

$cat ./script.php
#!/usr/bin/php -q -d include_path=foo
<?php
echo "Hello World";
?>

---
Depending on wich shell you run it from, php receives
"php" "-q -d include_path=foo" "./script.php" (linux)
"php" "-q" "./script.php" (solaris)
as argv, leading to problems...

Solution ? Ahem... Nasty one : #!/bin/bash /usr/bin/php -q -d include_path=foo <<EOF <?php echo "Hello World"; ?> EOF

Flavien Lebarbe.

---------------------------------------------------------------------------

Full Bug description available at: http://bugs.php.net/?id=5076

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>