php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #40144 Returning int . string gives parse error
Submitted: 2007-01-16 13:47 UTC Modified: 2013-02-17 12:47 UTC
Votes:4
Avg. Score:1.8 ± 0.8
Reproduced:2 of 3 (66.7%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: Quis at omicidio dot nl Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.2.0 OS: FreeBSD
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Quis at omicidio dot nl
New email:
PHP Version: OS:

 

 [2007-01-16 13:47 UTC] Quis at omicidio dot nl
Description:
------------
Unexpected parse error

Reproduce code:
---------------
Not working:
echo 1.'sometext';
or,
return 1.'sometext';

Working:
$i=1;
echo $i.'sometext';

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

Actual result:
--------------
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-16 13:50 UTC] Quis at omicidio dot nl
The 'actual' code I got this error on was:
echo 1.str_repeat('sometext', 3);
Also resulting in Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
 [2007-01-16 14:03 UTC] tony2001@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


 [2007-01-16 14:17 UTC] Quis at omicidio dot nl
Well,
Then i`ll make it an RfC :)
 [2013-02-17 12:47 UTC] nikic@php.net
1. is a floating point literal, so what you have there is a float followed by a string (with nothing in between), which give you the error. We can't really fix this unless we remove the short floating point syntaxes (1. and .1). I don't think we will do that (just for BC reasons already).
 [2013-02-17 12:47 UTC] nikic@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 12:01:32 2024 UTC