How to use php nl2br function

藏色散人
Release: 2023-04-04 22:30:01
Original
3077 people have browsed it

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)
Copy after login

Parameters:

string Required. Specifies the string to check.

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

Description: Insert an HTML newline character (
or
).

php nl2br() function usage example:

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

Output:

First line.
Second line.
Copy after login

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!

Related labels:
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