php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #17561 str_repeat with 0 multiplier
Submitted: 2002-06-02 03:06 UTC Modified: 2002-06-02 12:58 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: lee at piclab dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.2.1 OS:
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: lee at piclab dot com
New email:
PHP Version: OS:

 

 [2002-06-02 03:06 UTC] lee at piclab dot com
str_repeat() has the arbitary restriction that the multiplier argument has to be greater than zero.  This is pointless and annoying.  It's obvious that the right thing to do is to return an empty string for a multiplier of zero, and this can be done with one line of code along the lines of

  if ( 0 == mult ) return "";

Why not remove this restriction?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-02 05:14 UTC] derick@php.net
There is no such restriction:

[derick@kossu derick]$ php
<?php
$a = 'test';
$b = 0;
echo "[".str_repeat ($a, $b)."]\n";
?>
[]

And the source as only this message:
"Second argument to %s() has to be greater than or equal to 0"

Derick
 [2002-06-02 11:52 UTC] lee at piclab dot com
In that case, it's no longer a feature request--it's a document bug.  The document is very clear in stating that the argument must be greater than zero.
 [2002-06-02 12:58 UTC] derick@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Nov 19 19:00:01 2025 UTC