Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.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
Php 对&;in header()函数_Php - Fatal编程技术网

Php 对&;in header()函数

Php 对&;in header()函数,php,Php,我正在这样做: $perf = get_query_var('goperf'); $campaignid = get_option('campaign_id'); $url = 'http://ww.mysite.com?test=1&testtwo=2'; header("HTTP/1.1 301 Moved Permanently"); header('Location: '.$url); exit; 我应该使用: $url = 'http://ww.mysite.com?tes

我正在这样做:

$perf = get_query_var('goperf');
$campaignid = get_option('campaign_id');
$url = 'http://ww.mysite.com?test=1&testtwo=2';
header("HTTP/1.1 301 Moved Permanently");
header('Location: '.$url); 
exit;
我应该使用:

$url = 'http://ww.mysite.com?test=1&testtwo=2';
或者我应该对&进行编码?使用&而不是&

$url = 'http://ww.mysite.com?test=1&esttwo=2';

TY

如果要将URL插入HTML文档,则应仅使用htmlencoded变体

因此,如果你有:

<a href="<?php echo $url;?>">click me!</a>

或者其他非第一种情况,不要htmlencode。

如果URL插入到HTML文档中,则应仅使用htmlencode变体

因此,如果你有:

<a href="<?php echo $url;?>">click me!</a>

或者不是第一种情况的任何其他情况,不要htmlencode。

第一种情况。在浏览器中尝试这两种方法,其中只有一种方法将get值传递给脚本。第一种方法。在你的浏览器中尝试这两种方法,其中只有一种方法会将get值传递给你的脚本。我这样做是为了重定向附属链接。。。当我编码时,重定向后不会传递我的参数。。。所以你是对的,我不应该对他们进行编码我这样做是为了重定向会员链接。。。当我编码时,重定向后不会传递我的参数。。。所以你是对的,我不应该给他们编码