I want to call a JavaScript function through PHP and store the returned value in a PHP variable. How to do this?
You can't do that - javascript being a client side technology will execute after your PHP script has already finished so there's no way to do what you are looking to accomplish.