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

187
Visualizações
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 Respostas
Responde à pergunta

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 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