From:             gclift at gtsquared dot com
Operating system: Linux  2.4.21-27.0.2.ELsmp #1
PHP version:      4.3.11
PHP Bug Type:     Strings related
Bug description:  str_pad and str_repeat return wrong string

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 bug report at http://bugs.php.net/?id=32989&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32989&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32989&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32989&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32989&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32989&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32989&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32989&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32989&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32989&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32989&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32989&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32989&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32989&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32989&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32989&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32989&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32989&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32989&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32989&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32989&r=mysqlcfg

Reply via email to