New line in PHP compatible with all operating system

Hello,
In very many open source scripts and books is a code similar to this one that determines the creation of a new line compatible for all operating systems.


<?php
function newLine() {
  if (strtoupper(substr(PHP_OS,0,3)=='WIN')) {
    $eol = "\\r\
";
  } elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')) {
   $eol="\\r";
  } else { 
   $eol="\
";
  }
  return $eol;
}

echo "my texte" . newLine();

but I do not understand why people do this if PHP offers a constant for this “PHP_EOL”
There he thus a reason for that?

No reason, just many people don’t know about the PHP_EOL constant. Just like many don’t know there is an Environment.NewLine constant in .NET

Depends how old the code is as well. PHP_EOL was not available until version 4.3.10

Okay, thanks!