I got this error when I am trying to run a simple PhP script via php.exe. The name of the script is gulliver ( no extension), and I type this into my command prompt:
php %Dir%\gulliver
Here’s the content in the gulliver file:
<?php //***************** Operating Systems parameters ************************** if ( PHP_OS == 'WINNT' ) define('PATH_SEP', '\\'); else define('PATH_SEP', '/'); //***************** Defining the Home Directory ********************************* $docuroot = explode ( PATH_SEP , $_SERVER['PWD'] );
The error occured was PHP notice: Undefined index: PWD in %Directory%gulliver.
Any idea how to solve this problem?
I could not find PWD in the manual page for $_SERVER. To find out which indexes are defined use var_dump($_SERVER);
If you need the ‘current working directory’, use the getcwd() function.
PS: Instead of defining your own PATH_SEP, you could use the predefined constant DIRECTORY_SEPERATOR.