Page 1 of 1

[SOLVED] String Concatenation

Posted: Mon Jan 03, 2005 4:30 pm
by irishmike2004
Hi All:

Been looking at the PHP documentation for a while and wondered if it is just not possible or what i am doing wrong to get a string built.

I am looking to concatenate bits into one variable. here is what i am trying:

Code: Select all

<?php
$string = $someVar + ": " + $anotherVar;

?>
The hope was to achieve the following output when you echo the string:

contentsofsomeVar: contents of anotherVar

Help is greatly welcomed

Posted: Mon Jan 03, 2005 4:35 pm
by protokol

Code: Select all

<?php
$string = $someVar . ': ' . $anotherVar;
?>

I feel stupid now... 16 hours straight coding

Posted: Mon Jan 03, 2005 4:36 pm
by irishmike2004
I knew this, just wasn't thinking.

Thanks all... it is solved.

Posted: Mon Jan 03, 2005 4:43 pm
by John Cartwright
or

Code: Select all

<?php
$newvar = "$somevar : $anothervar";
?>
read the php manual on the difference of single and double quotes