Corentin Branquet Corentin Branquet - 4 months ago 7
PHP Question

Combine two strings PHP

My

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

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

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

Output:- https://eval.in/618282

Or may be like this you want:-

https://eval.in/618286

Comments