You can do this without putting a username or password in your script.
In your crontab sudo, execute the script as the user your web server is working with. Following your example, I will use the user nobody.
0 12 * * * (sudo -u nobody php./yourscript.php)
, "nobody" ( , "apache" ) . sudo tty. , , : "sudo: , tty sudo"
, "Defaults requiretty", visudo. sudo, , .