Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /homepages/24/d152177141/htdocs/techblog.tonycollings.com/wp-content/plugins/code-highlighter/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /homepages/24/d152177141/htdocs/techblog.tonycollings.com/wp-content/plugins/code-highlighter/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /homepages/24/d152177141/htdocs/techblog.tonycollings.com/wp-content/plugins/code-highlighter/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /homepages/24/d152177141/htdocs/techblog.tonycollings.com/wp-content/plugins/code-highlighter/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /homepages/24/d152177141/htdocs/techblog.tonycollings.com/wp-content/plugins/code-highlighter/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /homepages/24/d152177141/htdocs/techblog.tonycollings.com/wp-content/plugins/code-highlighter/geshi.php on line 2147

Huh! This is an interesting dilemma I came across today. Take some fairly standard PHP export script:

  1. span style="color: #ff0000;">"Content-type: application/vnd.ms-excel""Content-Disposition: attachment; filename=some-filename.xls");
  2.  

... set some headers and print($sMyCSVFile);. Well NOT so much with Internet Explorer. Works perfectly with everything else.

Turns out that there is a known issue opening documents over SSL with Internet Explorer. (MSDN Article: 316431) and it's all to-do with caching! If EITHER of the following headers exist then the script will fail:

  1.  

The answer; it turns out, is relatively easy. Simply set :

  1.  

.. Voila! There are also some nice examples of forcing file-download on php.net (http://us3.php.net/manual/en/function.readfile.php)


Further Reading: