Corentin Branquet Corentin Branquet - 1 year ago 53
PHP Question

Combine two strings PHP


script has to display this string :

Hello world

For doing this, I'm trying to write this code but it does not work :

$output = "Hello";
$output += "world !";

return $output;

I'm working on a word-press short-code but it displays nothing.

Thanks for your help !

Answer Source

You have to use . (php concatenation operator to add strings) rather than + like below:-

$output = "Hello"; $output .= " world"; echo $output;


Or may be like this you want:-