Appending strings

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
jdizzle
Forum Newbie
Posts: 5
Joined: Fri Jun 18, 2004 12:06 am

Appending strings

Post by jdizzle »

How do I append strings that contain numbers for their values?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Code: Select all

$num = 15;
$text = "Number is: ";
$text = $text . $num;  //or $text .= $num
echo $text; //returns Number is: 15
I think this is what your asking....
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the concatenation operator: . (period)

example:

Code: Select all

<?php

$foo = 123;
$bar = 'jerry';

$baf = $foo.$bar;

echo $baf;

?>
Post Reply