我有一个html文件,其中内联php。index.html大致如下所示
<?php session_start(); echo $_SESSION['xxx']; ?>
<form action=blah.php> ... </form>
在blah。php中,输入
$_SESSION['xxx'] = "foo";
header('Location: index.html');
但是,当第二次显示index.html时,我没有看到"foo"消息。
然后检查服务器设置。尝试在地址行设置发送会话值(如GET请求)
在开始会话之前运行这段代码。访问会话文件
有可能出错。ini_set("display_errors", "stdout"); error_reporting(E_ALL);
PHP不能用HTML文件解析,PHP代码不能用HTML运行,你可以试试
<!--#include FILE="test.inc" -->
以上代码是HTML文件包括,并把你的PHP代码。inc文件,但你必须做一些改变在Apache