我想要访问html选择标记中的php会话变量,以便我可以使用它来确定如何填充选项。读取html选择标记中的php会话变量
如果我在select标签之外回显变量,它可以正常工作,但它不会在标签内回显。
我没有经验知道为什么。
以下是代码片段,我删除了不相关的代码,以使其更易于阅读。
<?php
session_start();
$_SESSION['profile_type']='test';
?>
<!doctype html>
<html lang="en">
<head>
<title>Profile</title>
</head>
<?php
echo $_SESSION["profile_type"]; //This WILL echo.
?>
<select id="profile" name="profile">
<?php
echo $_SESSION["profile_type"]; //This will NOT echo.
?>
</select>
我在完整的代码中有选项,我不认为这是问题所在。我需要能够读取此会话变量以确定如何填充选项 – user3101337
您能否以此为基础显示您的代码?可能会有一个比较语法错字,或其他的东西。 –
现在我明白了,谢谢。 – user3101337