In order to get error messages into error.log, they just have to be written to the STDERR file handle.
You could have done that using this:
openlog('PHP_Err: ', LOG_PERROR | LOG_CONS | LOG_NDELAY | LOG_PID, LOG_USER)
Where LOG_PERROR indicates to also write the message to STDERR in addition to the system logger.
Keep in mind the system logger is a separate daemon running on the server and keeps its own log files. So when you use it, it writes to log files in the /var/log directory and in this case your error messages will be written in two different places. It won't break your script doing it this way, and only the root user can read the /var/log/user.log file as well.
Customer since 2000 openvein.org