despite some comments, at some cases it's really necessary to access PHP functions at Javascript (e.g. the AJAX cases).
At these cases you can use the mwsX library to use your PHP functions at Javascript.
mwsX library: https://github.com/loureirorg/mwsx