Usually, when i need to use some php in javascript code, i use to put the code into the head like this :
<script>
$(function() {
$("input#datepicker").val('<?php echo $date ?>');
});
</script>
This way, i can use some php variables in javascript code. It works fine.
Do you know how to do this if i want to put all javascript code in an external js file :
<script type="text/javascript" src="js/admin.js"></script>
Maybe it doesn’t matter at all. But i use to code in an external js file and and i’m wondering if it’s possible to do that.
You would need to make the js file a php file.
If you still want to keep the js extension, you need to do a rewrite for your webserver.
js/admin.php
if you want the js extension here is an example rewrite.
Nginx
Apache