how to write new lines in CLI and web browser?

php

Solution

You could write a function to return the right thing based on the execution environment:

<?php 
if (PHP_SAPI === 'cli') 
{ 
   return PHP_EOL;
} 
else
{
   return "<BR/>";
}
?> 

Problem

I am running a php script from CLI command and web browser. I need to dispaly new lines properly in both ways so that it does not print `"<br />"` in CLI and it shows new lines in browsers. Does anyone know how to write php function for this? thanks for any helps

Original source