S
S
Senseich2018-03-13 13:41:13
PHP
Senseich, 2018-03-13 13:41:13

Why doesn't PHP throw an error on extra characters?

The question is strange, but I'm wondering why php does not react in any way to errors in the code?
Actually, I read the following:

If you (accidentally) leave a newline character after the PHP closing tag ('?>'), you may see an error message such as "Headers already sent" for example. So if you see this error in the output, double check your PHP file for a space or newline after the closing tag.

And I decided to check:
5aa7a9cf4b4dc974313347.jpeg
But everything is displayed great, no matter how many spaces and line breaks I do. Why is that?
Why am I interested? I myself am still studying the basics, but somewhere I heard that in PHP you can’t leave extra spaces, something like that)
I’m trying on OpenServer, PHP 7.2 installed

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Lazy @BojackHorseman PHP, 2018-03-13
Tag

where did you read that? php does not interpret anything outside of <?php ?> tags. and just add them to the output stream

S
SagePtr, 2018-03-13
@SagePtr

It may also be due to the fact that output_buffering is enabled.
Or the output of error messages is disabled.

N
Nurlan, 2018-03-13
@daager

For example, this will break:
php.net/manual/ru/function.header.php
php.net/manual/ru/function.setcookie.php
There are situations when the fact that you "passed" something to the user prevents another from working code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question