Skip to content
Advertisement

how to include js file in php?

I have a problem with an js file in php. if i include it like this:

JavaScript

the file isn’t included and i get an error that the function isn’t defined.

When i try it this way:

JavaScript

the first tag in the document.write function closes <script type="text/javascript">

what is the correct way to do this?

thanks, sebastian

Advertisement

Answer

PHP is completely irrelevant for what you are doing. The generated HTML is what counts.

In your case, you are missing the src attribute. Use

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement