0

I have this function in my PHP code.

<?php
 $user = get_user_by_id($user_id);
?>

And I also have a JavaScript code on the same page. The JavaScript generates some value to a JS variable.

What I need to do is, using that JavaScript variable value as the argument of the above PHP function.

So, what's the simplest method for achieving this..?

Tharindu Thisarasinghe
  • 3,846
  • 8
  • 39
  • 70

1 Answers1

1

That's not quiet possible. You can't use client side variables (ECMA Script) inside your server side scripts (PHP). You may be able to achieve this by creating a web service and passing the variables using XHTTP Requests (AJAX) or reload the page using ECMA Script passing the value as a parameter and using it server side.

I don't know what exactly you are trying to do so I can't give you a definitive answer to this.

Hikaru-Shindo
  • 1,891
  • 12
  • 22