Estoy usando php para agrupar archivos javascript y CSS.
... $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); } ...Pero cuando los agrego a mi página HTML:
<script src="http://localhost:63342/project/assets/assets.php"></script> me da error de sintaxis Uncaught SyntaxError: illegal character U+0001
...function(){ S.event.add(this�Yÿø��, t, i, r, n) }... �Yÿø�� es una cadena ilegal, pero mi código original es correcto:
...function(){ S.event.add(this, t, i, r, n) }... ¡también probé readfile() y mb_convert_encoding() para codificar pero aún no funciona!
Manualmente está funcionando correctamente:
<script src="http://localhost:63342/project/assets/jQuery/jquery.3.6.js"></script>Puede configurar el encabezado así: header('Content-Type: text/html; charset=utf-8');
para evitar el problema.