What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

How should one format returned errors or console messages in a question on Stack Overflow?

Recently I ran into a PHP question that had an error as a code block:

PHP Warning:  file_get_contents(http://www.google.com/): failed to open stream: 
Network is unreachable in /var/www/api/get_contents.php on line 2

Whatever, I guess it looks fine, but the automatic syntax highlighting kind of makes it a little bit difficult to read.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Formatting these "output" messages as code blocks is just fine. If the automatic syntax highlighting proves bothersome, you can add an explicit syntax hint to disable it:

I get the following warning:

<!-- language: lang-none -->

    PHP Warning:  file_get_contents(http://www.google.com/): failed to open stream: 
    Network is unreachable in /var/www/api/get_contents.php on line 2

Alternatively, you can abuse inline code formatting (using backticks), to which syntax highlighting is never applied. That would look like this:

`PHP Warning:  file_get_contents(http://www.google.com/): failed to open stream: 
Network is unreachable in /var/www/api/get_contents.php on line 2`

and render like this:

PHP Warning: file_get_contents(http://www.google.com/): failed to open stream: Network is unreachable in /var/www/api/get_contents.php on line 2

share|improve this answer
    
Good tip on the explicit language declare. Thank you. –  ChristopherW Mar 29 '13 at 22:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .