php

You are currently browsing the archive for the php category.

I just came across a subtle issue affecting Internet Explorer users (well, fancy that!) and HTTPS connections.

One of my clients has a site that downloads a series of results as a CSV file, which they open in Excel. Unfortunately, Internet Explorer was refusing to download the file, and was presenting an error message reading “Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found.”

To add to my confusion, this was happening on the live server (PHP4), but not on my dev server (PHP5) which both use the same code.

In the end, I happened upon a Microsoft Knowledge Base article that explained the problem. Basically, IE obeys any “no-cache” headers you send to the browser. Without caching the file, Office applications cannot open the file when served over HTTPS.

How to solve the issue? Remove the cache header(s) - but how?

The PHP manual doesn’t make it entirely clear, and I found the solution by accident. To remove a header, use the same syntax as for setting a header, but only include a space after the colon.

For example, for the “Pragma” header:

header('pragma: ');

Note: You must include the space after the “:” or the header will not be unset.

As many coders will tell you, there reaches a point where you realise that you absolutely, positively must keep your code in a a revision control system. In my working life, I’ve used Microsoft’s ageing SourceSafe and more recently the vastly superior SubVersion (SVN).

There’s many powerful GUIs out there which you can use to interact with SVN, and make the checking out and checking in very easy. If you primarily use a desktop GUI (like me), then chances are you use a SVN client GUI to interact with SVN on a day-to-day basis.

But what happens when you need to move code between repositories?

Read the rest of this entry »

I’ve just discovered, totally by accident, how to get HTTP Authentication (when the browser pops up a dialog asking for the username and password - usually set with a .htaccess file) values within PHP. Previously, I’d just assumed that the authentication was a “black box” and I was unable to use it within my scripts. I had done some experimentation to see if any of the information was present in the _POST or _COOKIE arrays to no avail.

Read the rest of this entry »