Were you using PHP as an Apache module (as opposed to PHP in CGI mode)? If yes then your problem is very likely a duplicate of ticket #1975 and we should close as DUPLICATE.
If not then I'd suggest you re-test with a more recent MapServer (v5.2 or 5.3-dev) to see if the issue is still present. It may well have been fixed already.
I'll close as duplicate for now. Please reopen with more details if you were not using PHP as an Apache module.