2017-02-22 30 views
0

我在html中使用php变量。 $userProfile['institute']$userProfile['institute']非空时显示正确的值。当$userProfile['institute']为空时,它显示'/'。这里可能是什么问题?在HTML中使用php变量

Institute: <input type="text" name="institute" value=<?php echo $userProfile['institute']?> /><br /> 

回答

3

你缺少一套报价为你的价值属性

value="<?php echo $userProfile['institute']?>" 
+1

使用** htmlentities **来防止注入攻击是一种很好的做法。 <?= htmlentities($ userProfile ['institute'])?> – user2182349

0

你应该加上双引号像这样(像你包裹类型和机构的价值属性)

Institute: <input type="text" name="institute" value=" <?php echo $userProfile['institute']?>" /><br />