PHP Handling Paths Across Platforms

PHP understands the use of either backward or forward slashes on Windows platforms, and can even handle paths that mix the use of the two slashes. As of version 4.0.7, PHP will also recognize the forward slash when accessing Windows UNC paths (i.e., //machine_name/path/to/file).

For example, these two lines are equivalent:

$fh = fopen(“c:/planning/schedule.txt”, ‘r’);
$fh = fopen(“c:\planning\schedule.txt”, ‘r’);

The Server Environment

The constant superglobal array $_SERVER provides server and execution environment information.

For example, here is a partial output of what is contained within it:

[“PROCESSOR_ARCHITECTURE”] => string(3) “x86”
[“PROCESSOR_ARCHITEW6432”] => string(5) “AMD64”
[“PROCESSOR_IDENTIFIER”] => string(50) “Intel64 Family 6 Model 42
Stepping 7, GenuineIntel”
[“PROCESSOR_LEVEL”] => string(1) “6”
[“PROCESSOR_REVISION”] => string(4) “2a07”
[“ProgramData”] => string(14) “C:\ProgramData”
[“ProgramFiles”] => string(22) “C:\Program Files (x86)”
[“ProgramFiles(x86)”] => string(22) “C:\Program Files (x86)”
[“ProgramW6432”] => string(16) “C:\Program Files”
[“PSModulePath”] => string(51)
[“PUBLIC”] => string(15) “C:\Users\Public”
[“SystemDrive”] => string(2) “C:”
[“SystemRoot”] => string(10) “C:\Windows”

Leave a Comment