Logo

Programming-Idioms

  • PHP
  • Pascal
  • Java

Idiom #59 Write to standard error stream

Print the message "x is negative" to standard error (stderr), with integer x value substitution (e.g. "-2 is negative").

System.err.printf("%d is negative", x);
System.err.format("%d is negative\n",x);
fwrite(STDERR, "{$x} is negative\n");

You can also use error_log().
Stderr is unusual in a PHP web server.
writeln(StdErr , x , ' is negative');

When argument indicates a text file or stream, WriteLn uses it as the output destination.
writeln(StdErr, Format('%d is negative',[-2]));
with Ada.Text_IO;
use Ada.Text_IO;
Put_Line (Standard_Error, Integer'Image (X) & " is negative");

New implementation...
< >
programming-idioms.org