Why does not any form of recording work? echo "Line 1 nr"; echo "line 2";

echo "Строка 1 \r\n"; echo "строка 2"; echo "Строка 1 \n\n"; echo "строка 2"; echo "Строка 1 \n\"; echo "строка 2"; 
  • I mean, doesn't it work? What is the result you want? - Ale_x
  • It is not entirely clear what you are doing, are you reading a PHP file with a C # program or are you sending an HTTP request to this file? - Andrey Arshinov
  • And don't forget about php.net/manual/en/function.nl2br.php and PHP_EOL - E_p

5 answers 5

 echo "Hello\n"; //перенос строки текст "как есть", если посмотреть исходный код страницы в браузере, то перенос будет заметен там echo 'Hello<br />'; //перенос строки в HTML, если смотреть не исходный HTML, а обработанный, то перенос будет именно в ней 

Do not confuse the line break with the new line, here’s another example:

 echo "\n\n"; //если выполнить этот код, а результат записать в файл, то любой текстовый редактор вам скажет, что здесь есть минимум две строки echo '<br /><br />'; //а если сделать то же самое с этим кодом, то тут будет всего одна строка по мнению текстового редактора 
  • ps: \n not fashionable, PHP_EOL taxis. - E_p

Where is the conclusion going? If HTML is in the browser, then <br> , if in the console or file - \n

     может где чего-то настроить надо? 

    kidding me? =)

    Try this:

     echo "Строка 1 <br>"; echo "строка 2"; echo "Строка 1<br><br>"; echo "строка 2"; echo "Строка 1 "; echo "строка 2"; 

    In general, it is interesting to know what specifically does not work for you. Everything is working)

    • I get the code of the html page through C #, I need to transfer the line without <br> if it is possible - johniek_comp

    See the source code. Everything works, I saw.

      We need to put the header at the beginning of the code:

       header("Content-Type: text/plain; charset=utf-8"); echo "раз ...\n"; echo "два ...\n"; echo "три ...\n";