我正在尝试从数据库中获取一些数据以在输入字段中使用,但它仅部分显示。
我已经将问题缩小到与我的数据库没有任何关系。简单地执行以下操作仅显示"一个,"...
<input type="text" value=<?php echo "one, two, three"; ?>>
当我加载页面时,输入字段只有"一",第一个逗号后没有任何内容。
但是,如果我像这样取出 PHP,它会显示整个事情......
<input type="text" value="one, two, three">
例如,我可以将 php 代码粘贴到文本区域中,它按预期显示整个内容,只有当我在输入字段中尝试时才会出现问题。有什么想法吗?
此外,如果我像这样去掉逗号后面的空格,它会显示所有内容......
<input type="text" value=<?php echo "one,two,three"; ?>>
如果这有帮助的话,我正在使用 PHP 版本 7.3.5。
使用此代码:
<input type="text" value=<?php echo "one, two, three"; ?>>
与以下相同:
<input type="text" value=one, two, three>
因此,请将代码从:
<input type="text" value=<?php echo "one, two, three"; ?>>
自:
<input type="text" value="<?php echo "one, two, three"; ?>">