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
<script>
function trim(str){
// str. remove whitespaces from left. remove whitespaces from right
return str.replace(/^\s+/g, "").replace(/\s+$/g, "");
}
</script>
String.prototype.trim = trim;
The Apache and PHP i'm using comes from xampplite from apachefriends.org.
I didn't make any configuration changes.
<?
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