php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38098 String concatenation
Submitted: 2006-07-13 15:12 UTC Modified: 2006-07-13 15:15 UTC
From: wiart at yahoo dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.1.4 OS: Linux (Fedora core 4) - AMD64
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wiart at yahoo dot com
New email:
PHP Version: OS:

 

 [2006-07-13 15:12 UTC] wiart at yahoo dot com
Description:
------------
reproduced with PHP 5.1.2 (sorry, no time to test with 5.1.4).

Impossible to concatenate strings in a class member declaration, it generates a PHP "Parse error".

Very annoying when, for example, one want to create a member string which is a concatenation of a text and a constant


Reproduce code:
---------------
<?php

class MyClass {
	public $myString = 'test1'.'test2';
}

$myClass = new MyClass();
echo "Result is: ".$myClass->myString;

?>

Expected result:
----------------
Result is: test1test2

Actual result:
--------------
Parse error: parse error, unexpected '.', expecting ')' in /home/wiart/genomequest/apache/web/GQ/lib/comparisonNew/HTMLlaunchform.php on line 5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-13 15:15 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


 [2010-07-23 11:34 UTC] nicolas dot hureau at kwift dot com
Actually, operations are not permitted while declaring properties or class 
constants, and that is quite annoying.
For example:
public $two = 1 + 1;
or
const two = 1 + 1;
or
public static $two = 1 + 1;
won't compile.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Dec 14 04:00:01 2025 UTC