我有一个奇怪的问题,我试图用速记PHP来输出保存在会话中的值.(基本上,如果您在注册时输入用户名和电子邮件地址,但是您收到的电子邮件地址有误,而不是清除用户名字段,它应该保留,然后您只需要记录错误的详细信息.)
这就是我对输出的看法:
value="<?=$usern_value;?>"
Run Code Online (Sandbox Code Playgroud)
在我的输入中:
<input type="text" id="inputUser" name="username" placeholder="Username" value="<?=$usern_value;?>" />
Run Code Online (Sandbox Code Playgroud)
但它输出了这个:

这$usern_value是创建值的位置:
<?php
if(isset($_SESSION['status']['register']['username'])){
$usern_value = $_SESSION['status']['register']['username'];
} else {
$usern_value = "";
}
?>
Run Code Online (Sandbox Code Playgroud)
试试这样吧
value="<?php echo $usern_value;?>"
Run Code Online (Sandbox Code Playgroud)
因为你的php版本可能没有启用速记.我所以你需要在配置文件中启用short_open_tag选项php.ini.你可以尝试以下之一
short_open_tag = On在php.ini中设置指令(推荐方式);ini_set("short_open_tag", 1);你的代码;将以下行添加到.htaccess文件中:
php_value short_open_tag 1
不建议您使用短标签(<??>).你应该使用全长标签(<?php?>).不推荐使用短语法,如果要使应用程序可移植,则可能在其他服务器上不允许使用短打开标记,因此应用程序将中断.