E
E
Evgeny Ivanov2018-03-04 14:30:11
PHP
Evgeny Ivanov, 2018-03-04 14:30:11

Why do spaces and line breaks appear?

Unfortunately, I can’t post a code example (a lot of code), or repeat the error on a test example (everything works there).
I have a php file which is included in index.php (include_once).
When calling index.php from a browser, program (post request), line breaks appear as a result

\n\n\n\n\n\n\n\n \r\n\r\n\r\n\r\n\r\n\r\nРезультат!

But I don’t have an output (echo) anywhere in my files that will output these hyphens, codes, symbols.
What I noticed.
If there are line breaks in my code
<?php
echo 'Результат';
//Ниже пустые переносы строк. Обозначаю тут их точкой т.к. этот редактор убирает пустые переносы
?>
.
.
.

Then they turn into these \n\n\n\
Finding all this is possible, but problematic. It looks like it's not just them.
What I can't understand. I am writing a code AND it should only output this line. Why and where do line breaks appear in the output? I'm not asking you to take it out. It's generally out of code. Why do spaces and line breaks appear?
echo 'Результат';

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gleb Starkov, 2018-03-04
@logpol32

Remove the closing tag ?>
Because the server sends everything outside the php tags to the browser as it is.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question