Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda