Here's an update to tomwk's code:
function safe_virtual( $filename )
{
$curDir = getcwd();
virtual ( $filename );
chdir( $curDir );
}
This is better if you've already changed your current directory to be something other than your script's directory. It works for PHP4 and above.