how can i call a php function from javascript
You can't. You have to understand that JavaScript is a client-side language (usually it is) and PHP a server-side language. Unless you use JavaScript as server language, this is not possible, at least to my knowledge.
fLIPIS
the closest you can have is for javascript to fill some hidden form fields in a form and then submit the form to a page with the php function on it.