$var = \"Hi there\".\"
\".\"Welcome to my website\".\"
;\"
echo $var;
Is there an elegant way to handle line-breaks in PHP? I\'
For linebreaks, PHP as "\n" (see double quote strings) and PHP_EOL.
Here, you are using , which is not a PHP line-break : it's an HTML linebreak.
Here, you can simplify what you posted (with HTML linebreaks) : no need for the strings concatenations : you can put everything in just one string, like this :
$var = "Hi there
Welcome to my website
";
Or, using PHP linebreaks :
$var = "Hi there\nWelcome to my website\n";
Note : you might also want to take a look at the nl2br() function, which inserts before \n.