PHP file_get_contents() not working when + (plus) sign is in file name -


i have couple of files have plus sign in name, , cannot seem able open them, function interprets space.

example:

file name: report_tue-jun-02-2015-14:11:04-gmt+0200-(w.-europe-daylight-time).html 

and when try open it:

warning: file_get_contents(/cores/report_tue-jun-02-2015-14:11:04-gmt 0200-(w.-europe-daylight-time).html) [function.file-get-contents]: failed open stream: no such file or directory in .... on line 150 

this code:

$file = $_get['file'];   $file = str_replace('+', '%2b', $file); $content = file_get_contents($file); 

any thoughts/solutions?

the following methods work fine me.

<?      # file name: report_tue-jun-02-2015-14:11:04-gmt+0200-(w.-europe-daylight-time).html       # method 1.      $file = 'report_tue-jun-02-2015-14:11:04-gmt+0200-(w.-europe-daylight-time).html';      $data = file_get_contents($file);      print($data);      # method 2.      $data = file_get_contents('report_tue-jun-02-2015-14:11:04-gmt+0200-(w.-europe-daylight-time).html');      print($data); ?> 

Comments