Access a JavaScript variable from PHP

后端 未结 8 950
萌比男神i
萌比男神i 2020-11-22 11:47

I need to access a JavaScript variable with PHP. Here\'s a stripped-down version of the code I\'m currently trying, which isn\'t working:

8条回答
  •  感情败类
    2020-11-22 11:58

    _GET accesses query string variables, test is not a querystring variable (PHP does not process the JS in any way). You need to rethink. You could make a php variable $test, and do something like:

    
    
    
    
    

    Of course, I don't know why you want this, so I'm not sure the best solution.

    EDIT: As others have noted, if the JavaScript variable is really generated on the client, you will need AJAX or a form to send it to the server.

提交回复
热议问题