ldsmike88 Posted March 16, 2007 Share Posted March 16, 2007 Can you insert php into a .js file? Thanks! Michael Link to comment https://forums.phpfreaks.com/topic/43024-php-in-a-js-file/ Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 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 More sharing options...
ldsmike88 Posted March 16, 2007 Author Share Posted March 16, 2007 So basically I would just have to name my javascript file a php file and it will work? Link to comment https://forums.phpfreaks.com/topic/43024-php-in-a-js-file/#findComment-208959 Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 As long as you send that header. Link to comment https://forums.phpfreaks.com/topic/43024-php-in-a-js-file/#findComment-208960 Share on other sites More sharing options...
ldsmike88 Posted March 16, 2007 Author Share Posted March 16, 2007 ok thanks Link to comment https://forums.phpfreaks.com/topic/43024-php-in-a-js-file/#findComment-208965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.