如何使用参数生成URL

时间:2018-02-21 21:51:25

标签: php session

如何使用$ _SESSION变量

中的参数生成URL
$action = (isset($_GET['action'])) ? $_GET['action'] : '';
    if($action == "first") {
        //$arrQuote = array();
        $_SESSION['arrQuote'][0] = '    
                <form method="post" action="index.php?action=second">
                    <div class="form-group"> <input type="text" class="form-control" name="klausimas_1"></div>
                    <button type="submit" name="submit_1" class="btn btn-default">Add Task</button>
                </form> 
        $key = array_rand($_SESSION['arrQuote']);
        echo $_SESSION['arrQuote'][$key];
        unset($_SESSION['arrQuote'][$key]);
    }

1 个答案:

答案 0 :(得分:1)

$_SESSION["color_1"] = "yellow";
$_SESSION["color_2"] = "red";
echo 'http://example.com?' . http_build_query($_SESSION);

输出:http://example.com?color_1=yellow&color_2=red