How do I turn on all error and warnings and log them to a file, but to set up all of that within the script (not changing anything in php.ini)?
I want to define a file name and so that all errors and warnings get logged into it.
Use the following code:
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
error_log( "Hello, errors!" );
Then watch the file:
tail -f /tmp/php-error.log
Or update php.ini
as described in this blog entry from 2008.