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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Mon May 12 20:01:27 2025 UTC