我是 PHP 新手,我需要有人指导我完成会话。我的意思是,你如何保存和检索变量。
我怎样才能得出这样的变量?
如何将它们从一页传递到另一页?
ps:我基本上是在要求关于会话的教程。
The PHP manual has a basic sessions usage tutorial.
<?php
session_start();
if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
} else {
$_SESSION['count']++;
}
Session variables persist between pages (as long as you call session_start()
on each one), you don't have to do anything to get them to pass.
Have a look at this tutorial, just to begin. It's very clear and it contains very good examples.
session_start();
在页面顶部开始会话使用。
要创建会话变量:
$myvariable = 1;
$_SESSION['variable'] = $myvariable;
现在创建另一个session_start();
顶部的页面
并打印会话变量,检查它是否存在,
if(isset($_SESSION['variable'])){
echo $_SESSION['variable'];
//which should print '1';
}
要取消设置会话,请使用 destroy_session();
我希望这有帮助。
谢谢
克里斯