From: mobanajp at yahoo dot co dot jp
Operating system: Win XP
PHP version: 4.3.7
PHP Bug Type: Strings related
Bug description: ereg_replace strange behavior
Description:
------------
Please compare this 3 script :
1. Simple Open a Page (everything going well)
<?
$buf = "";
$fp = fopen("http://poxy.x0.com/deai/html/index.html", "r");
if($fp) while(!feof($fp)) $buf.=fread($fp, 1024);
echo $buf;
?>
2. Simple Open A Page and eliminate the line break (THE PAGE CUT IN
MIDDLE)
<?
$buf = "";
$fp = fopen("http://poxy.x0.com/deai/html/index.html", "r");
if($fp) while(!feof($fp)) $buf.=fread($fp, 1024);
$buf = ereg_replace("\r|\n", "", $buf);
echo $buf;
?>
3. Open page using File and eliminate line-break per array elements
(everything going well)
<?
$buf = file("http://poxy.x0.com/deai/html/index.html");
foreach($buf as $key=> $value) {
$buf[$key] = ereg_replace("\r|\n", "", $buf[$key]);
}
$buf = implode("", $buf);
$buf = ereg_replace("\r|\n", "", $buf);
echo $buf;
?>
Reproduce code:
---------------
<?
$buf = "";
$fp = fopen("http://poxy.x0.com/deai/html/index.html", "r");
if($fp) while(!feof($fp)) $buf.=fread($fp, 1024);
$buf = ereg_replace("\r|\n", "", $buf);
echo $buf;
?>
Expected result:
----------------
the page without break line
Actual result:
--------------
half of the page without break line
--
Edit bug report at http://bugs.php.net/?id=29348&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29348&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29348&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29348&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29348&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29348&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29348&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29348&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29348&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29348&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29348&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29348&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29348&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29348&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29348&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29348&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29348&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29348&r=float