Avatar of ariestav
ariestav

asked on 

How can I get new lines in php error reporting messages?

Simple question, but can't find the answer.

When my PHP script generates multiple errors or warnings, etc. they all appear without any line breaks.  I have to figure out where each error message starts and stops.  How can I configure my php setup so that it places new line breaks after each error message so it is easier to decipher when it displays in my browser.

ALSO, I want to do this globally to the server, not just a particular script.

Thanks!
PHPWeb DevelopmentWeb Frameworks

Avatar of undefined
Last Comment
ariestav
Avatar of Cornelia Yoder
Cornelia Yoder
Flag of United States of America image

What kind of errors or warnings are you getting?  Syntax errors usually die after the first one.  
Avatar of ariestav
ariestav

ASKER

my error reporting is set to E_ALL.  So the warnings are annoyingly difficult to decipher.  
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Please post a link to a web page that generates the kind of messages you describe, thanks.
Avatar of Hugh McCurdy
Hugh McCurdy
Flag of United States of America image

Since you are interested in an answer for the server, I'm going to assume you control the server.  (Have admin access.)

The errors might be easier to read in the error_log file.  On my development computer, the file is in the folder /var/log/httpd
Look at the end of that file.  In Linux, I use the tail command to look at the last few lines.  My log file gives me the line # where the error occurred.  

On my system, the location of the error_log file is defined in /etc/httpd/httpd.conf


There are controls for how php behaves in the php.ini file.  On my development computer, php.ini is in a folder called /etc/httpd

In the meantime, I'm with Ray on this one.  It would really help to see the errors.
Avatar of ariestav
ariestav

ASKER

The errors are "Notices" and "Warnings", they are not syntactical.  These errors output to the webpage for which the scripts builds after the request is done.  I don't want to look in an error_log file to find out what the error is--I already know what the error is.  I just want the format / display of the errors that appear in my output / echo's to be formatted better.

Thanks!
Avatar of Hugh McCurdy
Hugh McCurdy
Flag of United States of America image

Would this work for you?

echo "Warning: phone number not specified<br />";
echo "Warning: zip code doesn't match state<br />";

Open in new window

Avatar of ariestav
ariestav

ASKER

They would, but there is no way to add br's to errors output by the php parser.  I can't get ahold of the engine that outputs those.  If I could, I would manipulate each string that gets output from there.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of ariestav
ariestav

ASKER

Thank you Ray.  This was good.  I hadn't thought of doing that.  I agree that fixing them is better.  But in some cases, I want to be able to decipher the messaging coming from PHP.  This will help.
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo