Let a thousand string concatenations bloom14 Nov 2007
How many different ways (in PHP) are there to concatenate the string values in two variables and put the result in a third variable?
Here are a few to start:
$alice = $bob . $charlie;
$alice = "$bob$charlie";
$alice = sprintf('%s%s', $bob, $charlie);
ob_start(); echo $bob, $charlie; $alice = ob_get_clean();
$alice = implode('', array($bob,$charlie));
I would say something like “Of course, this entire exercise is just for fun and in practice is totally useless,” but whenever I start out thinking that something actually productive eventually emerges. So perhaps this is totally useless, perhaps not!