PHP script as Cron job

I want to execute a php script regularly, and for that reason I created a cron job through WHM. The file is indeed executed, but it fails to do so correctly. I receive this error:

/home/site/cron.php: line 1: ?php: No such file or directory
/home/site/cron.php: line 3: =: command not found
/home/site/cron.php: line 4: =: command not found

etc.

After searching I find this has to do with the format of the script. I wrote this as if it is made for usage through a browser, but now I read that it should be adapted in order to work as a cron. However, I can not find how to change this. Anyone any ideas?

Your problem is that your system does not know how to run /home/site/cron.php . This file is not a binary file, it needs to be interpreted with php (as other need perl, python, etc) so the system HAS to know how to run it.

In theory it would be enough to insert a Shebang line in your script, but this would case error from the php interpreter itself.