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

186
Vistas
Illegal character in javascript with php header

I am using php to bundle javascript and CSS files.

...
$js_files = ['path/to/script.js', 'path/to/jquery.js'];

header( "Content-type: application/javascript" );

foreach($js_files as $path){
   echo file_get_contents($path);
}
...

But when I add them to my HTML page:

<script src="http://localhost:63342/project/assets/assets.php"></script>

it gives me syntax error Uncaught SyntaxError: illegal character U+0001

...function(){
   S.event.add(this�Yÿø��, t, i, r, n)
}...

�Yÿø�� is an illegal string, but my original code is correct:

...function(){
   S.event.add(this, t, i, r, n)
}...

also tried readfile() and mb_convert_encoding() for encoding but still not working!

Edit

Manually it's working correctly:

<script src="http://localhost:63342/project/assets/jQuery/jquery.3.6.js"></script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can set the header like that: header('Content-Type: text/html; charset=utf-8');

to avoid the problem.

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