这是我的网页标题:
<?php
header("Location: http://sreyas.org.in/main/index.php?user=<?php echo
$_SESSION['username']; ?>"); exit;
header('Content-Type: text/html; charset=UTF-8');
header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate,
post-check=0, pre-check=0'); // HTTP 1.1.
header('Pragma: no-cache'); // HTTP 1.0.
header('Expires: 0');
?>
但是我在我的网页上看到的是以下错误:
解析错误:语法错误,unexpected " (T_ENCAPSED_AND_WHITESPACE), expect identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:'wamp'www'sreyas'main'index.php on line 5
我能做什么?
header()函数已经在PHP标记中。你不需要把它们加倍。所以试试这个:
header("Location: http://sreyas.org.in/main/index.php?user=".$_SESSION['username']);
为什么又在
中启动PHP<?php
header("Location: http://sreyas.org.in/main/index.php?user=<?php echo
$_SESSION['username']; ?>");
?>
直接使用
<?php
$name=$_SESSION['username'];
header("Location: http://sreyas.org.in/main/index.php?user=".$name);
?>