php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20448 I can't concat a string with +=
Submitted: 2002-11-15 10:45 UTC Modified: 2002-11-15 10:48 UTC
From: 00664714 at academ01 dot gda dot itesm dot mx Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.2.3 OS: Windows 2000
Private report: No CVE-ID: None
 [2002-11-15 10:45 UTC] 00664714 at academ01 dot gda dot itesm dot mx
Hi! I have the following code:

   $a_data = array("a","b","c");
   
   $s_data = "";
   
   foreach($a_data as $data){
       $s_data += $data;
   }
   
   echo $s_data;

I was trying to make $s_data contain "abc" but instead I get a 0. It seems that += cube of types returns an int ignoring that the user is trying to concat an string.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-15 10:48 UTC] iliaa@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

strings should be concatinated using a '.'
ex: $b .= "a";
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 04:01:29 2024 UTC