In python built-in web server when use print in function, it prints result in terminal ...
for example:
Django version 1.3.4, using sett
php built-in server writes output to the php://stdout stream , which mean you can output anything to it, but this should only be used for debugging.
here's a quick example of how can you achieve the result of writing to the server console :
$args
*
* @return void
*/
public static function log(...$args): void {
foreach ($args as $arg) {
if (is_object($arg) || is_array($arg) || is_resource($arg)) {
$output = print_r($arg, true);
} else {
$output = (string) $arg;
}
fwrite(STDOUT, $output . "\n");
}
}
}
// usage example :
ServerLogger::log('Hello, world!');
// outputting an array :
ServerLogger::log($_SERVER);