<script src="https://stackoverflow.com/path/to/my/file.php"></script>
In file.php
you’ll also want to output the correct header, before outputting anything you should have the following:
header("Content-Type: application/javascript");
EDIT: As @Tony_A pointed out, it should be application/javascript
. I don’t think it mattered as much when I wrote this post in 2010 🙂