php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42321 fread is stripping text from the string before returning contents
Submitted: 2007-08-16 14:23 UTC Modified: 2007-08-16 22:22 UTC
From: babyluch06 at hotmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.3 OS: windows
Private report: No CVE-ID: None
 [2007-08-16 14:23 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-16 22:22 UTC] jani@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 05 16:01:31 2024 UTC