P
P
photosho2019-08-14 10:56:22
1C-Bitrix
photosho, 2019-08-14 10:56:22

Question regarding indentation problem before calling localRedirect()?

Explain, please, who understands such a question. In the init.php file (Bitrix), one of the classes of its own module is connected. This class had an extra indent (between two <?php ... ?> tags), which caused the "localRedirect()" function to stop working: I removed the indents and it worked. They write about this function that it works based on changing http headers (header), which can be changed only if there is no content on the page - any indents and even BOM characters in this case can be critical.
But in the same way, the component is connected in the index.php file, in which I call this very localRedirect (), and before connecting the component, the markup is displayed (and indents, respectively), and the redirection works.
Accordingly, I want to know what is the difference between the indents in your class (included in init.php) and in the index.php file:
1. It's just a coincidence that if there is markup in index.php, the redirection works - other errors may appear.
2. There is a difference between these files. What - I will explain in the comments.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Ekaterina, 2019-08-14
@photosho

2. The difference is that what is displayed in the template is first buffered (including in order for the setting of cookies, localRedirect, all sorts of pending functions, etc. to work), but init.php exclusively executes what what it says on each hit without any buffering.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question