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

113
Vistas
Include JavaScript files to the document head with php

I'm creating a blog where I included header.php(Header, included in every page). Header contains a section where all the scripts (Scripts that will need in every pages) will be included.

header.php

<!DOCTYPE html>
  <html>
    <head>
      <!-- Scripts Section -->
      <script src="example01.js"></script>
      <script src="example02.js"></script>
      <title>Demo</title>
    </head>
    <body>
      <p>Blog</p>

But in a specific page, I've to include a specific script (file.js named).

index.php

<?php
  include('header.php');
  importjs('file.js'); /* Any Function To Import JavaScript*/
?>

If I include the JavaScript file here then it'll be included in body not the scripts section in the header. I don't know how to create that function. So please tell me how to create that function. create function in header.php and please first include the header before using function.

Thank You

almost 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I think, you should to write your line code like this example:

<?php int a; ?> 
<script type="text/javascript" src="file.js" /> 
<?php int b; ?>
almost 4 years ago · Santiago Trujillo 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