php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49883 The parser doesn't distinguish periods after integers as concatenations
Submitted: 2009-10-15 01:27 UTC Modified: 2009-10-15 03:04 UTC
From: svavar at kjarrval dot is Assigned:
Status: Not a bug Package: Compile Failure
PHP Version: 5.2.11 OS: FreeBSD 7.2
Private report: No CVE-ID: None
 [2009-10-15 01:27 UTC] svavar at kjarrval dot is
Description:
------------
The parser thinks that a period after an integer must mean the number is a float, even though the period represents a concatenation of a string.

Reproduce code:
---------------
<?php
$time = 2000;

echo $time/1000.' seconds';         // doesn't work
//echo $time/1000..' seconds';        // works - when not commented out

?>

Expected result:
----------------
To see the following output:

2 seconds

Actual result:
--------------
The parser outputs a syntax error:

unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-15 03:04 UTC] scottmac@php.net
Surround your expression with parentheses to get your expected behavior.

The lexer treats this as a float, not the parser.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Sep 22 20:00:01 2025 UTC