Three things I discovered when trying to run my PHP applications on IIS.
The following will work fine running on Apache but will throw up all kinds of errors and warnings on IIS:
if(!$QUERY_STRING) fopen(”file”, rb )
1. Undefined variables.
$QUERY_STRING throws up an error since it is not defined. You need to use isset() to check if $QUERY_STRING is NULL.
if(!isset($QUERY_STRING)) fopen(”file”, rb )
2. External variables
OK, fixed that but $QUERY_STRING is still undefined. All external variables need to be explicitly referenced i.e. using $_SERVER, $_GET, $_POST, $_SESSION etc. as follows:
if(!isset($_SERVER[’QUERY_STRING‘])) fopen(”file”, rb )
3. File attributes in quotes
You’ll get a warning if you don’t put file attributes in quotes when using fopen.
if(!isset($_SERVER[’QUERY_STRING’])) fopen(”file”, “rb“ )
I think it’s good that you are forced to do this when running on IIS. The code is actually more robust and easier to read. It’s annoying that Apache allows you to get away with it. I don’t understand why it cannot be platform-neutral.
Mark Waters marked time at 6:35 pm on December 10th, 2003 .
