javascript variable into php

前端 未结 3 583
生来不讨喜
生来不讨喜 2020-12-07 04:54

I have a php function, in this function I have a javascript which get the value of my element from parent window. My problem now is, how can I pass this value into php varia

3条回答
  •  春和景丽
    2020-12-07 05:43

    PHP code runs on the server (before your code is sent to the client browser), and JavaScript on the client (after the code is sent to the client browser). I'm not sure there is any other way to pass information to the server, other than sending a request to the server. so if you want to send something to your PHP application (server side) you'll have to send a request from your JavaScript code (client side). you may use AJAX techniques, but this causes another PHP process on the server to start. so you'll have to find a way to communication between the base PHP process (who created the JavaScript) and the new process (called by the JavaScript) to pass information. you may use server side data persistence like sessions or files or databases, or inter-process communication solutions like shared memory. but I guess this will get a little more complicated in implementation.

提交回复
热议问题