How to add class or ID to div containing errors in PHP
When PHP encounters an error, it displays the Error or Warning message in a div
with some inline style. I wish to add a class="some-class"
or id="some-id"
attribute to the div
so that I can do a little styling in m开发者_开发百科y CSS file. Is that possible and how?
Never use an ID twice in the same page. PHP errors are printed en masse, so use a class instead. Find the following two lines in your php.ini
file (on my Ubuntu box, it's in /etc/php5/apache2/php.ini
:
error_prepend_string
error_append_string
And change them to suit your needs. I use inline styles with them so I don't have to add anything into my stylesheet, but you could of course add a class. This is my setup:
error_prepend_string = "<div style='font-weight: bold; color: red'>Error: "
error_append_string = "</div>"
Yours might be something like this:
error_prepend_string = "<div class='phpError'>Error: "
error_append_string = "</div>"
精彩评论