Michael
Michael

Reputation: 307

How can I string together different objects in PHP

I want to have a string all connect together so I can just echo one defined group. I thought this might work.

$randomnum = rand(500000,600000);
$refnum = (echo 'ST' . $randomnum . '-' . $coupon_id . '-' . $userid . '');
$refnum;

Upvotes: 0

Views: 52

Answers (2)

ceejayoz
ceejayoz

Reputation: 180024

You're almost there. You can't assign echo to a variable like that.

$randomnum = rand(500000,600000);
$refnum = 'ST' . $randomnum . '-' . $coupon_id . '-' . $userid . '';
echo $refnum;

Upvotes: 4

Ryan
Ryan

Reputation: 28187

Just do

$refnum = 'ST' . $randomnum . '-' . $coupon_id . '-' . $userid;

Upvotes: 1

Related Questions