我想做一些非常简单的事情。用户在 HTML 文本框中输入文本然后点击提交后,PHP 回显输入的文本。我到处搜索,但找不到如何做!一定有什么办法!我想要这样的东西,除了 $foo
是输入的文本。
<html>
<input type="text" name="something" value="$foo"/>
<html>
<?php
echo $foo = "ben";
echo "foo is $foo"; // foo is foobar
?>
最佳答案
傅立叶
<html>
<head><title>some title</title></head>
<body>
<form method="post" action="">
<input type="text" name="something" value="<?= isset($_POST['something']) ? htmlspecialchars($_POST['something']) : '' ?>" />
<input type="submit" name="submit" />
</form>
<?php
if(isset($_POST['submit'])) {
echo 'You entered: ', htmlspecialchars($_POST['something']);
}
?>
</body>
<html>
关于php - 输入 PHP 后显示带有回显的输入文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9046353/