passing variables from php file to anther

前端 未结 4 1198
[愿得一人]
[愿得一人] 2021-01-23 04:11

How to pass variables from a php file to another while it is not html inputs ,just i have a link refer to the other file and i want to pass variables or values to it

Exa

4条回答
  •  被撕碎了的回忆
    2021-01-23 04:57

    Use sessions to store any small value that needs to persist over several requests.

    File1.php:

    session_start();
    $_SESSION['var'] = 'foo';
    

    File2.php:

    session_start();
    $var = $_SESSION['var'];  // $var becomes 'foo'
    

提交回复
热议问题