Home  >  Article  >  Backend Development  >  printf controls newline

printf controls newline

WBOY
WBOYOriginal
2016-08-18 09:16:073041browse

A program needs to use the printf function to format and wrap lines after printing.
I finished it like this
php > printf("%s",7);
7
php > printf("n");

The following method can be run, but it does not break the line
php > printf("%s",7)."n";
7
I don’t want to write
echo sprintf("%s",7)."n";
Excuse me, is there any clever way?

Reply content:

A program needs to use the printf function to format and wrap lines after printing.
I finished it like this
php > printf("%s",7);
7
php > printf("n");

The following method can be run, but it does not break the line
php > printf("%s",7)."n";
7
I don’t want to write
echo sprintf("%s",7)."n";
Excuse me, is there any clever way?

Please look at your code carefully printf("%s", 7) . "n", your "n" is outside printf and will not be printed at all, so there is no need to wrap it in a new line.

printf("%sn",7)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn