-3

我是 PHP 新手,我需要有人指导我完成会话。我的意思是,你如何保存和检索变量。

我怎样才能得出这样的变量?

如何将它们从一页传递到另一页?

ps:我基本上是在要求关于会话的教程。

4

3 回答 3

3

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.

于 2013-01-19T22:32:00.360 回答
0

Have a look at this tutorial, just to begin. It's very clear and it contains very good examples.

于 2013-01-19T22:29:43.780 回答
0

session_start();在页面顶部开始会话使用。

要创建会话变量:

$myvariable = 1;
$_SESSION['variable'] = $myvariable;

现在创建另一个session_start();顶部的页面

并打印会话变量,检查它是否存在,

if(isset($_SESSION['variable'])){

echo $_SESSION['variable'];

//which should print '1';

}

要取消设置会话,请使用 destroy_session();

可以在此处找到我用来学习 PHP 会话的出色而简单的教程

我希望这有帮助。

谢谢

克里斯

于 2013-01-19T22:33:41.813 回答