PHP – String spanning multiple lines

PHPstring

I'm fairly new to php. I have a very long string, and I don't want to have newlines in it. In python, I would accomplish this by doing the following:

new_string = ("string extending to edge of screen......................................."
    + "string extending to edge of screen..............................................."
    + "string extending to edge of screen..............................................."
    )

Is there anything like this that I can do in PHP?

Best Answer

You can use this format:

$string="some text...some text...some text...some text..."
."some text...some text...some text...some text...some text...";

Where you simply use the concat . operator across many lines - PHP doesn't mind new lines - as long as each statement ends with a ;.

Or

$string="some text...some text...some text...some text...";
$string.="some text...some text...some text...some text...";

Where each statement is ended with a ; but this time we use a .= operator which is the same as typing:

$string="some text...some text...some text...some text...";
$string=$string."some text...some text...some text...some text...";