H
H
Hecktosaurus2021-04-28 16:52:59
1C-Bitrix
Hecktosaurus, 2021-04-28 16:52:59

Why is ob_start() resetting?

Site on Bitrix. It is necessary to perform some manipulations with the markup on the pages; To do this, I wanted to buffer the output in the template, then process the received and give it to the visitor, but found that ob_get_clean () returns only part of the html. Example:

<?

// Включаю буферизацию
ob_start();

?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?=LANGUAGE_ID?>" lang="<?=LANGUAGE_ID?>" <?=($htmlClass ? 'class="'.$htmlClass.'"' : '')?>>
<head>
  <!-- разметка -->
</head>

<!-- дальше идёт разный код -->

</html>
<?php

    // пытаюсь получить буфер и просто вывести его,
    // но получаю фрагмент не с 7 строки, а уже откуда-то в конце
    $modified_output = ob_get_clean();
    echo $modified_output;

?>


Just wondering why ob_start () / ob_get_clean () does not return all the markup, but only a piece?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adamos, 2021-04-28
@Hecktosaurus

Bitrix buffers everything itself. From the moment the header was connected to the very footer. Here you are in conflict with him.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question