将值插入到 echo 语句内的文本框中
我有这个代码基础:
echo '<input required type = "text" name = "subject1" value="XXX" />';
但是,我希望 XXX 成为一个变量,我已经在网上搜索了这个,但是其中一个讨论所说的所有事情都是这样做:
value=\"$firstName\"
或者
value='$firstName'
我已经尝试过这两种方法,但他们没有不起作用,我希望有人可以帮助我解决这个问题,基本上,我想要的是能够将文本编辑的值分配给php中的变量,但是当文本编辑本身嵌入到回声,似乎没有任何作用。
谢谢
I have this code basis:
echo '<input required type = "text" name = "subject1" value="XXX" />';
However, I would like XXX to be a variable, I have searched this online, but all the things that one of the discussions says is to do this:
value=\"$firstName\"
or
value='$firstName'
I have tried both of these, but they don't work, and I was hoping that someone could help me with this problem, basically, what I want is to be able to asign the value of a text edit to a variable in php, but when the text edit itself, is embedded in an echo, nothing seems to work.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
连接是一种非常简单的方法:
编辑:连接 . 周围的空格(
. $foo .
)不是必需的 - 我只是将它们添加到可读性中。Concatenation is a pretty easy way to go about this:
edit: Those spaces around the concatenation .'s (
. $foo .
) aren't required - I just add them fore readability.我认为问题是您使用的是单引号,因此变量不会自动呈现...您可以像这样与
.
连接:I think the problem is you are using single quotes, so variables are not rendered automatically... you can concat with
.
like this:实际上你不需要 php echo .... 东西... /* 大脑没有参与 */
acutally you don't need the php echo .... stuff.... /* brain not engaged */