Bug #76729 [NEW]: php -r command fails on valid PHP code, variable assignment from include

From: Date: Fri, 10 Aug 2018 20:32:17 +0000
Subject: Bug #76729 [NEW]: php -r command fails on valid PHP code, variable assignment from include
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216712@lists.php.net to get a copy of this message
From:             info at kelmmoyles dot com
Operating system: SmartOS / Solaris 11
PHP version:      7.1.20
Package:          PHP options/info functions
Bug Type:         Bug
Bug description:php -r command fails on valid PHP code, variable assignment from include

Description:
------------
php -r "$config = include 'LocalConfiguration.php'"

fails with:

PHP Parse error:  syntax error, unexpected '=', expecting end of file in
Command line code on line 1

even though the code itself is valid PHP that runs fine when executed
from within a PHP file, e.g.:

config.php
<?php

$config = include 'LocalConfiguration.php';

?>

and then run:

php config.php

FYI: The file referenced above is a config file from the Typo3 CMS,
where its config in stored in an array, e.g.:

https://forge.typo3.org/attachments/23893/LocalConfiguration.php

Actual OS used is "SunOS host 5.11 joyent_20180315T080815Z" with PHP
from pkgsrc:

PHP 7.1.13 (cli) (built: Apr  8 2018 19:57:49) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.13, Copyright (c) 1999-2017, by Zend
Technologies

Test script:
---------------
- download
https://forge.typo3.org/attachments/download/23893/LocalConfiguration.php
to a local directory

- in that same directory run:
 php -r "$config = include 'LocalConfiguration.php'"

Expected result:
----------------
same behavior regardless whether the PHP code is read/executed from a
PHP file or executed via the command line using "php -r"

Actual result:
--------------
"php -r" execution fails with this code

-- 
Edit bug report at https://bugs.php.net/bug.php?id=76729&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=76729&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=76729&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=76729&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=76729&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=76729&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=76729&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=76729&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=76729&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=76729&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=76729&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=76729&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=76729&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=76729&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76729&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=76729&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=76729&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=76729&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76729&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=76729&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=76729&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#216712) next »