doujie7346 2014-03-20 16:39
浏览 32
已采纳

PHP不会以速记方式输出值

I have a weird issue where I am trying to use PHP in shorthand to output a value saved in the session. (Basically, if you type in a username and email address when signing up, but you get the email address wrong, instead of it clearing the username field it should persist and then you only have to recorrect the incorrect details.)

This is what I have for the output:

value="<?=$usern_value;?>"

Which is in my input:

<input type="text" id="inputUser" name="username" placeholder="Username" value="<?=$usern_value;?>" />

But it outputs this instead:

enter image description here

This is where the value of $usern_value is created:

<?php 
   if(isset($_SESSION['status']['register']['username'])){
        $usern_value = $_SESSION['status']['register']['username'];
   } else {
        $usern_value = "";
   }
?>
  • 写回答

5条回答 默认 最新

  • doutuo1939 2014-03-20 16:41
    关注

    Try like this

    value="<?php echo $usern_value;?>"
    

    Because may be shorthand is not enabled in your php version.I so you need to enable the short_open_tag option in the configuration file php.ini.You can try one of the following

    • set the directive short_open_tag = On in your php.ini (the recommended way);
    • call ini_set("short_open_tag", 1); in your code;
    • add the following line to your .htaccess file:

      php_value short_open_tag 1

    It's not recommend you use short tags (<? ?>). You should use the full length tags (<?php ?>). The short syntax is deprecated, and if you want to make your application portable, it's possible that short open tags are not allowed on another server and hence your application will break.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答