05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The following code shows how to test for a Windows platform prior to setting an<br />

include path:<br />

<br />

Handling Paths Across Platforms<br />

<strong>PHP</strong> understands the use of either backward or forward slashes on Windows platforms,<br />

and can even handle paths that mix the use of the two slashes. As of Version<br />

4.0.7, <strong>PHP</strong> will also recognize the forward slash when accessing Windows UNC<br />

paths (i.e., //machine_name/path/to/file). For example, these two lines are equivalent:<br />

$fh = fopen('c:/tom/schedule.txt', 'r');<br />

$fh = fopen('c:\\tom\\schedule.txt', 'r');<br />

The Environment<br />

<strong>PHP</strong> defines the constant array $HTTP_ENV_VARS, which contains the HTTP environment<br />

information. Additionally, <strong>PHP</strong> provides the getenv( ) function to obtain the<br />

same information. For example:<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!