Differences in PHP SAPIs

mod_php CGI CLI
Writes HTTP headers to output Writes HTTP headers to output unless '-q' given on command line No HTTP headers, even if header() is called
ini defaults are as specified in manual ini defaults are as specified in manual

Overrides some of the defaults:

chdir()s to the script directory chdir()s to the script directory unless '-C' given on command line Does not chdir() to the script directory
Sets superglobals appropriately, including server variables Sets superglobals appropriately, including (part of) server’s environment Most HTTP-related superglobals are empty arrays, except $_SESSION is NULL

About this entry