#42321 [Opn->Bgs]: fread is stripping text from the string before returning contents
| From: | jani@php.net | Date: | Thu, 16 Aug 2007 22:22:14 +0000 |
| Subject: | #42321 [Opn->Bgs]: fread is stripping text from the string before returning contents | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-116203@lists.php.net to get a copy of this message | ||
ID: 42321
Updated by: jani@php.net
Reported By: babyluch06 at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: windows
PHP Version: 5.2.3
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2007-08-16 14:23:09] babyluch06 at hotmail dot com
Description:
------------
I'm using fread to retrieve the contents of a .js file. If within the
file this string exists, '/g'. it strips this with a empty space and
'String' with empty space. If '/g' dosen't exists, everything works
fine.
heres the .js file
function trim(str){
// str. remove whitespaces from left. remove whitespaces from right
return str.replace(/^\s+/g, "").replace(/\s+$/g, "");
}
String.prototype.trim = trim;
The Apache and PHP i'm using comes from xampplite from
apachefriends.org. I didn't make any configuration changes.
I can send you the contents of phpinfo() if will help
Reproduce code:
---------------
if ($handle = @fopen($file, 'rb'))
{ $filesize = filesize( $file );
if ($contents = fread($handle, $filesize))
{
$contents = file_get_contents( $file );
if ( eregi( 'trim.js' , $file ) ) {
print "<br/><br/><h1>$contents</h1>";
}
return $contents; fclose($handle);
}
else
{
$GLOBALS['IG_ERROR_PHP'] = $php_errormsg;
$GLOBALS['IG_ERROR_SPEC'] = "$file";
IF ($return==TRUE)
return 'ERR0104';
ELSE
return FALSE;
}
}
Expected result:
----------------
return the full contents
Actual result:
--------------
It strips certain text out, as explained above
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42321&edit=1