输入PHP后显示输入的文字 [英] Display entered text with echo after input PHP
本文介绍了输入PHP后显示输入的文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ foo
是输入的文本是。 < html>
< input type =textname =somethingvalue =$ foo/>
< html>
<?php
echo $ foo =ben;
echofoo is $ foo; // foo是foobar
?>
解决方案
FTFY
< html>
< head>< title>一些标题< / title>< / head>
< body>
< form method =postaction =>
< input type =textname =somethingvalue =<?= isset($ _ POST ['something'])?htmlspecialchars($ _ POST ['something']):''?> ; />
< input type =submitname =submit/>
< / form>
<?php
if(isset($ _ POST ['submit'])){
echo'You entered:',htmlspecialchars($ _ POST ['something']] );
}
?>
< / body>
< html>
I want to do something very simple. After a user enters text in an HTML text box then hits submit, the PHP echo's the entered text. I searched all over and I cant find out how to do it! There must be some way! I want something like this except $foo
is what the entered text was.
<html>
<input type="text" name="something" value="$foo"/>
<html>
<?php
echo $foo = "ben";
echo "foo is $foo"; // foo is foobar
?>
解决方案
FTFY
<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后显示输入的文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文