Set phps $_REQUEST['variable_name'] in JavaScript

后端 未结 4 678
轮回少年
轮回少年 2021-01-21 20:00

is it possible to store a variable through javascript so that I can read it in php using $_REQUEST[\'variable_name\'].

for eg. let\'s say i have

$adcat         


        
4条回答
  •  不知归路
    2021-01-21 20:43

    Assuming you are using Apache:

    Try setting the default in a file (called "my_vars.php" in this example), then in your .htaccess file:

    php_value auto_prepend_file /absolute/path/to/my_vars.php

    For the js side, take the value of what you set in that file at page load.

    
    

    Research: http://www.google.com/search?aq=f&sourceid=chrome&ie=UTF-8&q=php_value+auto_prepend_file

    I have found that auto prepend is good if you want to use a sort of settings file for storing stuff like this, IMHO. That way you don't need to jump through hoops, the draw back is that it will be included on each page.

提交回复
热议问题