E-mail:vova@vbeg.ru
Skype:vova-beglecov

PHP. Data output in a variable (buffer) and send in email

Getting GET and POST data and send in email.

ob_start();

echo '----------------------------------------<br>';
echo 'GET<br><pre>'; print_r($_GET); echo '</pre><br><br>';
echo '----------------------------------------<br>';
echo 'POST<br><pre>'; print_r($_POST); echo '</pre><br><br>';
echo '----------------------------------------<br>';

$message_text = ob_get_contents();
ob_end_clean();

mail('mail@yandex.ru', 'Отладка', $message_text);

Description of functions
ob_start - turn on output buffering;
ob_get_contents - return the contents of the output buffer;
ob_end_clean - clean the output buffer and turn off output buffering;