我想通过使用变量名,使用URL传递php变量的值。这是我试图实现的目标的一个例子,它不起作用,但也不会崩溃,所以我知道我很接近。。。。任何人请:
<a href="student_what_learning_unit.php?student=<?php $student_user ?>">Unit Learning</a>
就我个人而言,我不喜欢在HTML中放一些PHP代码。这是可以做到的,但有问题。最好编写干净的PHP代码,如:
<?php
$url = 'student_what_learning_unit.php?student='.urlencode($student_user);
echo '<a href="'.$url.'">Unit Learning</a>';
您确实需要urlencode()
作为URL,请参阅:
http://php.net/manual/en/function.urlencode.php
只需添加一个echo
,如下所示:
<a href="student_what_learning_unit.php?student=<?php echo $student_user ?>">Unit Learning</a>