+ 2
Php variable in script
I am working on a web app. I am coming across situations where I need to access php variable in script and change its value. How can I accomplish this?
3 Answers
+ 8
You simply cannot do that. You can assign php value to javascript variable, but you cannot assign javascript value to php variable. understand the server side and client side first.
+ 5
yeah you must create an api in php
gabby is correct, directly, but by creating a form to post/get data to a php script which will give you access to the variables that you need it is possible and quite common I might add
server side -> client side is a one way street, but by creating a second script (or a function in the first) you can achieve 2 way communication
+ 2
yes you cant change server side value from client side so simply call Ajax to set or change value