php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60848 php -r works differently
Submitted: 2012-01-23 11:55 UTC Modified: 2012-01-23 14:27 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: public at grik dot net Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 5.4.0RC6 OS: linux
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: public at grik dot net
New email:
PHP Version: OS:

 

 [2012-01-23 11:55 UTC] public at grik dot net
Description:
------------
PHP behaves differently with the code given in a file and in a parameter provided 
with -r
php -r ignores variables, partially recognizes scalar type hinting.

Test script:
---------------
[root@devel data]# php -r "echo 1;"
1[root@devel data]# php -r "$x=3;"

Parse error: syntax error, unexpected '=' in Command line code on line 1


# php -r "var_dump($x);"

Warning: Wrong parameter count for var_dump() in Command line code on line 1

# php -r "function foo(int $a){}"

Parse error: syntax error, unexpected '(int )' (int) (T_INT_CAST), expecting '(' in Command line code on line 1

Expected result:
----------------
1

Actual result:
--------------
Parse errors

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-23 14:27 UTC] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

use single quotes, or there will be variable substitution of shell.
 [2012-01-23 14:27 UTC] laruence@php.net
-Status: Open +Status: Bogus
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Feb 07 00:01:29 2025 UTC