使用 $_GET 函数而不是使用纯文本
我的服务器上有一个名为“form2.php”的文件,它是这样的:
<form action="strlen2.php" method="get">
<input type="text" name="text13"/>
<input type="submit" value="Submit!"/>
</form>
我将其传输到另一个名为“strlen2.php”的文件,它是这样的:
<?php
$text="$_GET["text13"]";
$more="Too much! Take away some text.";
$equal="Great! You entered the right amount.";
$less="Not enough! Enter some more text.";
if(strlen($text)>3)
{
echo $more;
}
elseif(strlen($text)==3)
{
echo $equal;
}
else
{
echo $less;
}
?>
我可以在第 3 行更改什么让它执行 $_GET
函数而不是将其视为纯文本?
I have a file on my server called "form2.php", this is what it looks like:
<form action="strlen2.php" method="get">
<input type="text" name="text13"/>
<input type="submit" value="Submit!"/>
</form>
I have it transfer to another file called "strlen2.php", this is what it looks like:
<?php
$text="$_GET["text13"]";
$more="Too much! Take away some text.";
$equal="Great! You entered the right amount.";
$less="Not enough! Enter some more text.";
if(strlen($text)>3)
{
echo $more;
}
elseif(strlen($text)==3)
{
echo $equal;
}
else
{
echo $less;
}
?>
What can I change on line 3 that makes it execute the $_GET
function instead of looking at it as plain text?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
$_GET
是一个变量。删除它周围的引号。$_GET
is a variable. Remove the quotes around it.在 PHP 中,预定义的
$_GET
变量用于通过method="get"
收集表单中的值。如果您在
strlen2.php
中执行print_r($_GET);
,您将能够看到结果。In PHP, the predefined
$_GET
variable is used to collect values in a form withmethod="get"
.and if you do
print_r($_GET);
in yourstrlen2.php
, you'll be able to see the result.删除引号。 $_GET 不是一个函数,而是一个数组。
Remove the quotes. $_GET is not a function, but an array.
如果 $_GET['text13'] 的值恰好包含对函数的引用,则需要执行如下操作:
If the value of $_GET['text13'] DOES happen to contain a reference to a function, you would need to do something like this:
$_GET 不是一个函数;)它是一个变量。删除引号,它应该像一个魅力:)
例如:
$_GET is not a function ;) it's a variable. Remove the quotes and it should work like a charm :)
eg :
不要在作业周围加上引号!
Don't put quotes around the assignment!
这永远不会起作用:
用这个代替:
This would never work:
Use this instead:
试试这个:
Try this: