使用php发布输入的人口值,因为“

I'm trying to populate a html field using php but if there is a " on the variable it just closes the value paramenter. How can I prevent this from happening?

<input type="text" name="txtnome" class="form-control" value="<?php echo "$nome" ?>" required>

You can do this:

<input type="text" name="txtnome" class="form-control" value="<?php echo htmlspecialchars($nome) ?>" required>

http://php.net/manual/en/function.htmlspecialchars.php

Since

echo "$nome";
echo '$nome';
echo $nome;

are identical to each other, it'll only work with htmlspecialchars.