Fri, 20 Jun 08

Setting headers in a PHP include directive

Posted in Java, HTTP, PHP at 5:30 pm by moore | Permalink

I am currently working on a project that uses a PHP CMS for the bulk of the site. However, it pulls some content from a page generated by JSTL on a tomcat. I was using the fmt tag to do some pretty printing of numbers, and it looked fine when I viewed the content as served by tomcat. However, none of the formatting was carrying through when the PHP page included the jsp. Why? It appears that the fmt tag needs a locale. I confirmed that with wget.

Now, how to set the header with the PHP include. The include man page was no help, and mod_rewrite won’t let you modify headers, as far as I can tell. Once the request arrived to tomcat, that was too late.

Some digging around in the PHP documentation on fopen turned up this gem:

Click through for a code example. The aforementioned documentation talks about custom headers, but it worked for sending the Accept-Language header that the fmt tags needed.

Leave a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image

© Moore Consulting, 2003-2008


You are viewing a mobilized version of this site...
View original page here

How do you rate mobile version of this page?

Mobilized by Mowser Mowser