header value php


header value php

您好,这行代码有问题。

    header('Location: student.php?student_id='<?php echo $get->student_id ?>;

它给出的错误是:

分析错误:语法错误,意外的"?"在第28行上的C:''examplep''htdocs''Thesis ''svalidate_user.php中

感谢您的帮助。

错误是由<?php引起的。

不需要它,因为您已经在PHP上下文中了。由于<?不是一个有效的PHP运算符,而是一个"开放标记",因此您将收到一个语法错误。

这个代码应该是什么样子

header('Location: student.php?student_id=' . $get->student_id);

这是一个非常基本的问题,这表明您可以从阅读更多关于PHP语法和字符串连接的信息中受益。

不要在标头中使用echo。

header('Location: student.php?student_id=' . $get->student_id);
header('Location: student.php?student_id='.$get->student_id);