php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75842 String concatenation
Submitted: 2018-01-18 14:53 UTC Modified: 2018-01-18 14:56 UTC
From: george at t-c-n dot co dot uk Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.2.1 OS: Windows 10
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: george at t-c-n dot co dot uk
New email:
PHP Version: OS:

 

 [2018-01-18 14:53 UTC] george at t-c-n dot co dot uk
Description:
------------
Not sure if this is a bug or not but I guess reporting it anyway wouldn't hurt.

String concatenation with '=', should this be a syntax error?

Test script:
---------------
<?php

$x = 'hello' .
$y = 'world';

echo $x;

OR

<?php
$x = 'hello' . $y = 'world';

echo $x;

Expected result:
----------------
Syntax error?

Actual result:
--------------
'helloworld'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-18 14:56 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2018-01-18 14:56 UTC] requinix@php.net
No, it's valid syntax. Assignment is an expression that evaluates to the RHS value, so
  $x = 'hello' . $y = 'world';
works like
  $y = 'world';
  $x = 'hello' . 'world';
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC