Q:

call a javascript from php and store the return in a variable

I am wondering if there is any way to call a javascrip function from php and store the return value of the function in php variable.
Something like: 
<?php
  var p = test("something");
  echo p;
?>
<script>
 function test(elm){
     return elm+" anotherthing";
 }
</script>

A:

You cannot call and evaluate a javascript function from php code.
You could however make a request (e.g. AJAX) from the javascript test() function to your php code and read the value.

