When running PHP on the command line, if you want to include another file which is in the same directory as the main script, doing just<?phpinclude './otherfile.php';?>might not work, if you run your script like this:/$ /path/to/script.phpbecause the current working dir will be set to '/', and the file '/otherfile.php' does not exist, because it is in '/path/to/otherfile.php'.So, to get the directory in which the script resides, you can use this function:<?phpfunction get_file_dir() { global $argv; $dir = dirname(getcwd() . '/' . $argv[0]); $curDir = getcwd(); chdir($dir); $dir = getcwd(); chdir($curDir); return $dir;}?>So you can use it like this:<?phpinclude get_file_dir() . '/otherfile.php';chdir(get_file_dir());include './otherfile.php';?>Spent some time thinking this one out, maybe it helps someone :)