Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Newline in error_log() in PHP

Tags:

php

How can I insert a newline while using error_log() in PHP?

I tried to use <br> and \n, but those didn't work.

like image 728
Satish Avatar asked Jun 07 '10 06:06

Satish


People also ask

Where does PHP Error_log go?

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 is Error_log?

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.

Where does Error_log write to?

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.


1 Answers

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.

like image 89
Konerak Avatar answered Sep 25 '22 00:09

Konerak