Doc #80347 [NEW]: nl2br â DOES NOT Insert(s) HTML line breaks before all newlines in a string
From: mh at phoenixchange dot com
Operating system:
PHP version: 7.3.24
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:nl2br â DOES NOT Insert(s) HTML line breaks before all newlines in a string
Description:
------------
---
From manual page: https://php.net/function.nl2br
---
It is not true that: "nl2br â Inserts HTML line breaks before all
newlines in a string". It only does this if the string is double
quoted.
Generally perhaps there is no need to point this out, but on the nl2br
page it seems a central point.
User 'aabaev' posted the following 1 year ago, but as it's the fifth
comment in, past four that are pretty advanced. I found it only after
the penny had finally dropped:
double quotes !== single quotes
php > echo nl2br('\r\n');
\r\n
php > echo nl2br("\r\n");
<br />
The manual (at string.php) says:
"If the string is enclosed in double-quotes ("), PHP will interpret the
following escape sequences for special characters: ...
... Sequence: \n Meaning: linefeed (LF or 0x0A (10) in ASCII)"
but nl2br is needed to introduce a LF in this case ...
--
Edit bug report at https://bugs.php.net/bug.php?id=80347&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80347&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80347&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80347&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80347&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80347&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80347&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80347&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80347&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80347&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80347&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80347&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80347&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80347&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80347&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80347&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80347&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80347&r=mysqlcfg
Thread (2 messages)
- mh at phoenixchange dot com