0

In PHP, I am creating a long string, like this:

$cmd = "scp -P 435 xxxxxxxx@xxxxxxxxxxx:/var/backups/db/xxxxxxxxxxxxx{$todayTimestamp}*.sql.gz /var/xxxx/xxxx/xxxx/xxxx/"

In order to better display the code on the monitor, I would like to break it to a new line but I dont't want the $cmd variable to contain a new line character.

An easy solution would be:

$cmd = "__first_part__ ";
$cmd .= "__second_part__";

But I don't like that very much.

I bet there is a better way in PHP.

Does anybody know that, please?

Thanks,
Dan

4 Answers 4

3

I guess you don't want to use any function, array or anything like that but the only other coding style that comes to mind would be:

$cmd = "__first_part__ ".
"__second_part__";

its nearly the same, but at least you don't have to use the variable name all the time.

Sign up to request clarification or add additional context in comments.

Comments

2

Use an editor with line-wrapping, such as geany, vim, gvim, etc.

Comments

0

U dont't want to use \n for line break u can use <br />. $cmd = 'text <br /> test'; In php we have nl2br() function u can also use that.

1 Comment

That is still adding a line break to a command. The OP doesn't want that to happen. It is for editing purpose that the "wrapping" is required as far as I can tell
0

1st:

$text = "line one
line two
line three";

And another way:

$text = "line one".
        "line two".
        "line three";

1 Comment

your first solution would produce "\n" line breaks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.