php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42591 wordwrap doesn't generate warning message when width is given as -ne or 0 value
Submitted: 2007-09-07 16:30 UTC Modified: 2007-09-09 16:06 UTC
From: kraghuba at in dot ibm dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5CVS-2007-09-07 (snap) OS: linux, windows
Private report: No CVE-ID: None
 [2007-09-07 16:30 UTC] kraghuba at in dot ibm dot com
Description:
------------
wordwrap() doesn't generate warning message when width argument is given  as a negative or zero value. 

this is applicable to php5 and php6.

Reproduce code:
---------------
<?php
 $text = "The quick brown fox jumped over the lazy dog.";

 var_dump( wordwrap($text, 0, "<br/>\n") );
 var_dump( wordwrap($text, -1 , "<br />\n") );

 var_dump( wordwrap($text, 0) );
 var_dump( wordwrap($text, -1) );
?>

Expected result:
----------------
warning messages should be generated

Actual result:
--------------
string(85) "The<br/>
quick<br/>
brown<br/>
fox<br/>
jumped<br/>
over<br/>
the<br/>
lazy<br/>
dog."
string(93) "The<br />
quick<br />
brown<br />
fox<br />
jumped<br />
over<br />
the<br />
lazy<br />
dog."
string(45) "The
quick
brown
fox
jumped
over
the
lazy
dog."
string(45) "The
quick
brown
fox
jumped
over
the
lazy
dog."

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-08 01:52 UTC] crrodriguez at suse dot de
In case this is considered a bug ( IMHO it should emit such warning)

fix:

http://www.kissofjudas.net/patches/wordwrap.patch
 [2007-09-09 16:06 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

When the line length is <= 0 it leaves the string untouched, this is 
expected behavior.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC