简体   繁体   English

echo获取引号中的语法

[英]echo get syntax in quote

I have a script that send user to another url everytime he click (first click - first url, secound cluck - secound url etc.) 我有一个脚本,每次用户单击时,该脚本都会将用户发送到另一个URL(第一次单击-第一个URL,第二个敲响-第二个url等)

Here is the script: 这是脚本:

<?php           
function urlredirect()
{
$value=0;
$url =array(
'http://www.link1.com/',
'http://www.link2.com/',
'http://www.link3.com/',
'http://www.link4.com/',
'http://www.link5.com/',
); 
$urlc = count($url)-1;
if ($_COOKIE["cooki_name"]=='') 
  {
setcookie("cooki_name", $value,time()+86400);
header ("Location: $url[$value]"); 
  }
  if ($_COOKIE["cooki_name"]!='') 
       {
  $getcookie=htmlspecialchars($_COOKIE["cooki_name"]);
    if($urlc >$getcookie)
  {
  $getcookie=$getcookie+1;
  }
  setcookie("cooki_name", $getcookie,time()+86400);
  header ("Location: $url[$getcookie]");
  }
  }
   urlredirect(); 
    ?>

Now I need to add some echo and I do not know the right syntax. 现在,我需要添加一些回显,并且我不知道正确的语法。 Echo from get: 从得到的回声:

script.php?code=something script.php?code =某物

<?php           
function urlredirect()
{
$value=0;
$url =array(
'http://www.link1.com/HERE-IS-THE-PLACE-WHERE-I-NEED-TO-ADD-code',
'http://www.link2.com/',
'http://www.link3.com/',
....

I was trying to add it by echo $_GET["code"]; 我试图通过echo $ _GET [“ code”];添加它。 but I fail. 但我失败了

construct your array like this to paas the url parameter in url 像这样构造数组以暂停url中的url参数

$url =array(
 'http://www.link1.com/?code=some_value',
 'http://www.link2.com/?code=some_value',
 'http://www.link3.com/?code=some_value',
 'http://www.link4.com/?code=some_value',
 'http://www.link5.com/?code=some_value',
); 

Now on your redirected page you can use 现在,您可以在重定向页面上使用

echo $_GET['code'];

Edit Based on comments 根据评论编辑

$url =array(
 'http://www.link1.com/'.$_GET['code'],
 'http://www.link2.com/'.$_GET['code'],
 'http://www.link3.com/'.$_GET['code'],
 'http://www.link4.com/'.$_GET['code'],
 'http://www.link5.com/'.$_GET['code'],
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM