【问题标题】:Extracting url variable in php using $_GET[] [closed]使用 $_GET[] 在 php 中提取 url 变量 [关闭]
【发布时间】:2012-11-08 15:59:00
【问题描述】:

我有一个简单的 url,只是想在其中回显一个变量,但它不起作用。

这里是代码

<?php    
$name = "mysite";    
echo "<a href= 'BusinessDisplay.php?address = $name'> hello </a>";    
?>

<?php     
echo $_GET['address'];    
?>

【问题讨论】:

  • 只是为了确保 - 它们位于两个单独的文件中,对吗? :)
  • 顺便说一句:无论您要做什么,您都在生成无效的 URL。
  • 删除address = $name 周围的空格。您的网址应类似于 BusinessDisplay.php?address=$name
  • 您还想对 $name 进行编码。

标签: php url variables


【解决方案1】:

那个间距是错误的。

"<a href= 'BusinessDisplay.php?address = $name'> hello </a>";
--------------------------------------^-^

【讨论】:

  • $name 也应该是 URL 编码的。
  • @Lloyd:也许,也许不是。我不知道用例是什么:)
  • 没有选择您的答案,只是对其他人的提示:)
猜你喜欢
  • 2014-09-08
  • 1970-01-01
  • 1970-01-01
  • 2011-07-07
  • 2012-11-27
  • 2013-05-02
  • 1970-01-01
  • 1970-01-01
  • 2015-08-14
相关资源
最近更新 更多