You've got a relative path in there (localhost/cron.php) - always use the absolute path. When the cron job tries to run, its base directory may not be where you think it is. If it's your own cron (not root's), and you don't have write access to where it's starting, that could cause the issue.
crontab does not preserve your environment and so when your process is started it gets a fresh, clean and empty shell to work in.
"at" and "batch" on the other hand (from memory), do indeed preserve your shell environment.