How to combine two variables to make one?

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
michlcamp
Forum Commoner
Posts: 78
Joined: Mon Jul 18, 2005 11:06 pm

How to combine two variables to make one?

Post by michlcamp »

need to create one variable by combining two with an underscore between them, then post the new one to a field in the data table. Want to create ' bob_799' from the code below, but this isn't working...

Code: Select all

 
$user_id = "bob";
$license_num = "799";
$string= "$user_id"._."$license_num";
echo "$string";
 
only prints the underscore.
I don't exactly understand the proper use of quotes and periods in queries, so have been experimenting, but no luck so far..

how to write it properly?
any help appreciated in advance..
thanks,
mc
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: How to combine two variables to make one?

Post by aceconcepts »

Code: Select all

 
$user_id = "bob";
$license_num = "799";
$string= $user_id."_".$license_num;
echo $string;
 
Post Reply