#32989 [Opn->Bgs]: str_pad and str_repeat return wrong string
ID: 32989
Updated by: derick@php.net
Reported By: gclift at gtsquared dot com
-Status: Open
+Status: Bogus
Bug Type: Strings related
Operating System: Linux 2.4.21-27.0.2.ELsmp #1
PHP Version: 4.3.11
New Comment:
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
Read the manual again, pay close attention to the examples and the
order of parameters.
Previous Comments:
------------------------------------------------------------------------
[2005-05-09 17:10:59] gclift at gtsquared dot com
Description:
------------
str_pad returns the exact same string that was entered as the string
input.
str_repeat returns 0 length string.
'./configure' '--localstatedir=/var/hsphere/php'
'--with-apxs=/hsphere/shared/apache/bin/apxs' '--with-openssl=/usr'
'--with-zlib=/usr' '--with-zlib-dir=/usr' '--with-bz2=/usr'
'--enable-calendar' '--with-jpeg-dir=/usr' '--enable-ftp'
'--with-gd'
'--with-ttf' '--with-freetype-dir=/usr' '--enable-gd-native-ttf'
'--with-png-dir=/usr' '--with-gettext=/usr'
'--with-imap=/hsphere/shared' '--with-mysql=/usr' '--with-pgsql=/usr'
'--with-curl=/hsphere/shared' '--with-curlwrappers'
'--with-mhash=/usr'
'--with-iconv=/hsphere/shared' '--enable-sockets' '--with-zip=/usr'
'--enable-versioning' '--enable-track-vars' '--enable-trans-sid'
'--enable-bcmath' '--enable-mbstring' '--disable-debug'
Reproduce code:
---------------
<?php
echo "<br>Start Test!<br>";
echo "<pre>";
var_dump( str_repeat(4, "../") );
echo "\r\n";
var_dump( str_pad("TESTING", 6, "../", STR_PAD_LEFT) );
echo "\r\n";
var_dump( str_pad("TESTING", 6, "-==") );
echo "\r\n";
var_dump( str_pad("TEST", 4) );
echo "</pre>";
echo "<br>End Test!<br>";
exit(0);
?>
Expected result:
----------------
Start Test!
string(0) "../../../../"
string(7) "../../../../../TESTING"
string(7) "TESTING-==-==-==-==-==-=="
string(4) "TEST "
End Test!
Actual result:
--------------
Start Test!
string(0) ""
string(7) "TESTING"
string(7) "TESTING"
string(4) "TEST"
End Test!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32989&edit=1
Thread (2 messages)