使用 $_GET 函数而不是使用纯文本

发布于 2024-12-18 22:17:37 字数 615 浏览 2 评论 0原文

我的服务器上有一个名为“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

凉城凉梦凉人心 2024-12-25 22:17:37

$_GET 是一个变量。删除它周围的引号。

$text = $_GET['text13'];

$_GET is a variable. Remove the quotes around it.

$text = $_GET['text13'];
夏夜暖风 2024-12-25 22:17:37

在 PHP 中,预定义的 $_GET 变量用于通过 method="get" 收集表单中的值。

<form action="strlen2.php" method="get">

如果您在 strlen2.php 中执行 print_r($_GET);,您将能够看到结果。

In PHP, the predefined $_GET variable is used to collect values in a form with method="get".

<form action="strlen2.php" method="get">

and if you do print_r($_GET); in your strlen2.php, you'll be able to see the result.

掩耳倾听 2024-12-25 22:17:37

删除引号。 $_GET 不是一个函数,而是一个数组。

$text = $_GET["text13"];

Remove the quotes. $_GET is not a function, but an array.

$text = $_GET["text13"];
笑着哭最痛 2024-12-25 22:17:37

如果 $_GET['text13'] 的值恰好包含对函数的引用,则需要执行如下操作:

$text = $_GET['text13'];
$text();

If the value of $_GET['text13'] DOES happen to contain a reference to a function, you would need to do something like this:

$text = $_GET['text13'];
$text();
那伤。 2024-12-25 22:17:37

$_GET 不是一个函数;)它是一个变量。删除引号,它应该像一个魅力:)

例如:

$text=$_GET["text13"];
$more="Too much! Take away some text.";
$equal="Great! You entered the right amount.";
$less="Not enough! Enter some more text.";

$_GET is not a function ;) it's a variable. Remove the quotes and it should work like a charm :)

eg :

$text=$_GET["text13"];
$more="Too much! Take away some text.";
$equal="Great! You entered the right amount.";
$less="Not enough! Enter some more text.";
吃素的狼 2024-12-25 22:17:37
<?php

$text = $_GET["text13"];
....

不要在作业周围加上引号!

<?php

$text = $_GET["text13"];
....

Don't put quotes around the assignment!

如日中天 2024-12-25 22:17:37

这永远不会起作用:

$text="$_GET["text13"]";   

用这个代替:

$text = $_GET['text13'];

This would never work:

$text="$_GET["text13"]";   

Use this instead:

$text = $_GET['text13'];
热风软妹 2024-12-25 22:17:37

试试这个:

$text= $_GET["text13"];

Try this:

$text= $_GET["text13"];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文