http://foo.com?url= [ http://foo2.com?thing=blah ]
$thing変数を含むURL全体を$urlに格納したいと思います。
注:ブラケットは明確にするためのものです。
http://foo.com?url= [ http://foo2.com?thing=blah ]
$thing変数を含むURL全体を$urlに格納したいと思います。
注:ブラケットは明確にするためのものです。
使用urlencode()
:
$param = urlencode('http://foo2.com?thing=blah')
見たことがありますかhttp_build_query
(と組み合わせることもできますhttp_build_url
)?
$data = array(
'url' => 'ttp://foo2.com?thing=blah'
);
$url = 'http://foo.com?' . http_build_query($data);
注:これらにはPECL pecl_http >= 0.23.0
PHP関数を使用しますurlencode()
。
URLの値をurlhttp ://foo2.com ?thing=blahにしたいようです。あなたがする必要があるのは、urlencode()を使用してその値をエンコードし、URLに安全に含めることです。 http://php.net/manual/en/function.urlencode.php
次のようにurlencodeを使用します。
$url = 'http://foo.com?url=' . urlencode('http://foo2.com?thing=blah');
$par = urlencode('http://foo2.com?thing=blah');
$url = 'http://foo.com?url='.$par;
$url = urlencode("http://foo2.com?thing=blah");
header("location: http://www.example.com/?url=" . $url);