[SOLVED] String Concatenation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
irishmike2004
Forum Contributor
Posts: 119
Joined: Mon Nov 15, 2004 3:54 pm
Location: Lawrence, Kansas

[SOLVED] String Concatenation

Post 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
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post by protokol »

Code: Select all

<?php
$string = $someVar . ': ' . $anotherVar;
?>
irishmike2004
Forum Contributor
Posts: 119
Joined: Mon Nov 15, 2004 3:54 pm
Location: Lawrence, Kansas

I feel stupid now... 16 hours straight coding

Post by irishmike2004 »

I knew this, just wasn't thinking.

Thanks all... it is solved.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

or

Code: Select all

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