Home > Backend Development > PHP Tutorial > printf controls newline

printf controls newline

WBOY
Release: 2016-08-18 09:16:07
Original
3078 people have browsed it

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)

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template