Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
Bootstrap Cannot modify header information

I try to do a notification system , that play a sound each time some one make a new post. I am work in boostrap 4 I have chnge the way to do it by insert a javascript in the functions page but wen i call the javascript function give me all ways the same error of before I go to post only part of all the code because is dimention The sctipt i call is play_sound and i call in an echo like this

echo '<script type="text/javascript">play_sound();</script>';

and i get same error then before

This is my error

Warning: Cannot modify header information - headers already sent by (output started at /home/nicetaxi/public_html/helpers/Functions.php:1) in /home/nicetaxi/public_html/helpers/Functions.php on line 208

This is the line of my error

function redirect_to_page($path = null)
{
header("location:" . SITE_ADDR . $path);
}

How can i solve this error

This is the functions page

<script type="text/javascript">
function play_sound() {
    var audioElement = document.createElement('audio');
    audioElement.setAttribute('src', 'https://www.nicetaxi.eu/download/notifications.mp3');
    audioElement.setAttribute('autoplay', 'autoplay');
audioElement.setAttribute('muted', 'muted');
    audioElement.load();
    audioElement.play();
}
</script>
<?php
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Avoid echo statement before header(), triggers "Header has already been sent out error". If the echo is mandatory to use

Use javascript redirect instead window.location.href = 'url; //Will take you to url.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda