How can I insert a newline while using error_log()
in PHP?
I tried to use <br>
and \n
, but those didn't work.
The location of the error log file itself can be set manually in the php. ini file. On a Windows server, in IIS, it may be something like "'error_log = C:\log_files\php_errors. log'" in Linux it may be a value of "'/var/log/php_errors.
What Does Error Log Mean? In computer science, an error log is a record of critical errors that are encountered by the application, operating system or server while in operation. Some of the common entries in an error log include table corruption and configuration corruption.
There are two possible values for error_log: a custom log file and the syslog. If the syslog is used, then all PHP errors will be sent directly to the default system log file—in Linux, this is typically /var/log/syslog.
Use double quotes when adding the error message.
error_log("This is a two lined message. \nThis is line two.");
should work.
error_log('This is a one lined message. \nThis is the same line still.');
will not work: notice the single quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With