Append a message to the log file in the current directory

/**
 * Appends a message to the log file in the current directory.
 *
 * Message example: `$msg = sprintf( '[%s] Hello world!', date( 'Y-m-d H:i:s' ) );`
 *
 * @see https://wpcodebook.com/append-message-log-file-current-directory/
 * @see https://www.php.net/manual/en/function.error-log.php
 * @see https://www.php.net/manual/en/language.constants.magic.php#constant.dir
 */
error_log( $msg . PHP_EOL, 3, __DIR__ . '/' . 'log.txt' );

Leave a Comment