Jump to content

php in a .js file?


ldsmike88

Recommended Posts

Not unless the .js extension file is recognized as a php file. A suggestion would be this

 

<?php
// filename: jsCode.php
header("content-type:text/javascript");
// do php process here that needs to be done
?>
<!-- here should be the javascript you want to display

 

The will be recognized as a .js file and you can use php to do some processing.

Link to comment
https://forums.phpfreaks.com/topic/43024-php-in-a-js-file/#findComment-208957
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.