Home >Backend Development >PHP Tutorial >How to use php nl2br function

How to use php nl2br function

藏色散人
藏色散人Original
2019-01-31 09:44:523110browse

php The nl2br function means to insert an HTML newline mark before all new lines in the string. Its syntax is nl2br(string,xhtml). The parameter string is required and specifies the string to be checked, while xhtml is optional.

How to use php nl2br function

#How to use the nl2br function?

Function: Insert a newline character before a new line (\n) in the string.

Syntax:

nl2br(string,xhtml)

Parameters:

string Required. Specifies the string to check.

xhtml Optional. Boolean indicating whether to use XHTML-compatible line breaks: TRUE - Default. INSERT df250b2156c434f3390392d09b1c9563FALSE - INSERT 0c6dc11e160d3b678d68754cc175188a

Description: Insert an HTML newline character (0c6dc11e160d3b678d68754cc175188a or d711d59c19a602cae27dfddf51888202).

php nl2br() function usage example:

<?php
echo nl2br("First line.\nSecond line.",false);
?>

Output:

First line.
Second line.

This article is an introduction to the PHP nl2br function. I hope it will help you if you need Friends help!

The above is the detailed content of How to use php nl2br function. For more information, please follow other related articles on the PHP Chinese website!

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