I've searched a lot for this and I seem to get different answers.
In my situation, my jQuery function has to use a PHP variable from a different file.
How can I accomplish this? Clear and simple answer would be greatly appreciated.
You could use ajax to get the value from a function read about it here: http://codex.wordpress.org/AJAX_in_Plugins
you can also save the variable in the database with transients if the function runs on every load. http://codex.wordpress.org/Transients_API
Update: This is a ugly way to do this. In your template where you want to save the var:
And in your function:
In general, this function lets you localize your JS strings, but you can also use it to set global JS variables:
You can now acces the var in your JS File by