php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #49775 no return in example function in note
Submitted: 2009-10-05 09:31 UTC Modified: 2009-10-05 13:11 UTC
From: hubert at freejazz dot co dot uk Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: n/a
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hubert at freejazz dot co dot uk
New email:
PHP Version: OS:

 

 [2009-10-05 09:31 UTC] hubert at freejazz dot co dot uk
Description:
------------
Note #91828 Note to nl2br function entry in manual by leaf at leafo dot 
net on 26-Jun-2009 08:02, there is no return statement so function does 
not work

Reproduce code:
---------------
---
From manual page: function.nl2br
---
function mynl2br($text) {
   strtr($text, array("\n" => '<br />', "\r\n" =>'<br />'));
}

Expected result:
----------------
returns a string with newlines replaces by <br />s

Actual result:
--------------
returns nothing (needs a return before code on line 2 of function)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-05 13:11 UTC] rquadling@php.net
The example in the user note has been amended to 

<?php 
function mynl2br($text) { 
   return strtr($text, array("\r\n" => '<br />', "\r" => '<br />', "\n" 
=> '<br />')); 
} 
?> 
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Fri Oct 09 00:00:01 2026 UTC