Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7937791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:36:51+00:00 2026-06-03T22:36:51+00:00

i have a set of JavaScript files in /js directory. how to add PHP

  • 0

i have a set of JavaScript files in /js directory.
how to add PHP tags to Javascript File ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:36:52+00:00Added an answer on June 3, 2026 at 10:36 pm

    Exactly the same way you add them to any other text file. Open them in a text editor and start typing <?php etc.

    You need to make sure that PHP is used to process the files though. That is done, most easily, on most systems, by renaming them to have a .php file extension. You can also change your webserver’s configuration.

    If they are going to emit JavaScript, then you should make sure that they claim to be JavaScript, and not HTML (the default for PHP).

    <?php
        header("Content-Type: application/javascript");
    ?>
    

    It is typical that JavaScript files are sent with cache control headers that encourage heavy caching. If you add dynamic content to them, then be prepared to lose the benefits of that caching. If appropriate, use PHP to send suitable cache control headers with the JS.

    You may wish to consider keeping your logic in static JavaScript files and use PHP to just inject some dynamic data into a <script> element directly into the HTML document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have javascript file in following directory /static /handler.js /evercookie.js /jquery.js All I want
I am having a problem accessing the ViewData object through javascript. I have set
I have a problem with a javascript set of functions that I made. This
I have code in javascript which get keycodes of different keys and set it
I would like a JavaScript function to have optional arguments which I set a
How can I set a break point in a javascript function and have the
In Javascript, I have a variable that is set to a block of text
I have set up multiple targets in a single xml file. I expect all
I have a large directory structure with JavaScript, images, etc. that depend on each
Assuming I have a directory structure similar to: path_to_file/one/index.html How can I set my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.