Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在URL中发送php变量(get方法)_Php_Html_Get_Getmethod - Fatal编程技术网

在URL中发送php变量(get方法)

在URL中发送php变量(get方法),php,html,get,getmethod,Php,Html,Get,Getmethod,我想使用get方法发送一个值。代码是这样的 <td><a href="cart-remove.php?id={$row['id']}" class="remove_item_link"> Remove</a></td> 如何在cart-remove.php页面中获取该值?我知道一些问题的答案,但我正试图保持我的代码类似于我的导师代码,因为他将评分的项目。而且,这(上面提到的)是来自同一个线程。只有当这是带有双引号字符串的echo语句的一部分时,您

我想使用get方法发送一个值。代码是这样的

<td><a href="cart-remove.php?id={$row['id']}" class="remove_item_link"> Remove</a></td>

如何在cart-remove.php页面中获取该值?我知道一些问题的答案,但我正试图保持我的代码类似于我的导师代码,因为他将评分的项目。而且,这(上面提到的)是来自同一个线程。

只有当这是带有双引号字符串的
echo
语句的一部分时,您这样做才会起作用。但是您直接输出HTML,而不是使用
echo
,因此不能使用字符串缩进或替换

您需要以相同的方式执行此操作,所有其他
$row
元素都嵌入到脚本的前几行中

<td><a href="cart-remove.php?id=<?php echo $row['id']; ?>" class="remove_item_link"> Remove</a></td>

应主题作者的要求。 PHP编译器将忽略代码中的所有纯HTML,并将其原封不动地传递到web浏览器,因此您需要打开

但是,只有当文本已经在php处理程序中时,这才有效
<td><a href="cart-remove.php?id=<?=$row['id']?>" class="remove_item_link"> Remove</a></td>

否?还是我不明白这个问题@谢谢你,成功了。但我仍然不明白为什么我的导师和7年前的答案使用
{}
而不是
我想他是指这样的:
@ScreamX这样使用它,它是有效的。请发布你的完整答案,以便我可以将其标记为接受答案。你应该得到很多爱,谢谢你,很好用。当ScreamX评论时,我运行了它。但是我仍然不明白为什么我的老师和7年前的答案用{}代替老师犯了一个错误。他还说“在单引号内”,但变量替换只在双引号内起作用。谢谢您的时间。如果您已经在echo中,那么您可以同时使用这两种东西
{}
'
。但这个问题页面有6页长,我想我的指导老师确实遗漏了XD。href和class属性的单倒逗号。
<td><a href="cart-remove.php?id=<?php echo $row['id']; ?>" class="remove_item_link"> Remove</a></td>
<td><a href="cart-remove.php?id=<?=$row['id']?>" class="remove_item_link"> Remove</a></td>
<?php echo "<td><a href='cart-remove.php?id={$row['id']}' class='remove_item_link'> Remove</a></td>"; ?>
<td><a href="cart-remove.php?id=<?=$row['id']?>" class="remove_item_link"> Remove</a></td>