how to add a custom request header in php -
i want send custom header domain.
i tried following :
header("myheader: value1"); //i want redirect above header samplesite header('location: http://localhost/samplesite', false); exit;
and in samplesite, not myheader. how achieve it, please me.
you can send custom header file_get_contents() , give context.
it this:
$data = http_build_query(array("username" => $uid)); $opts = array ( 'http' => array ( 'method' => 'post', 'header'=> "content-type: application/x-www-form-urlencoded\r\n" . "content-length: " . strlen($data) . "\r\n", 'content' => $data ) ); $context = stream_context_create($opts); $returneddata= file_get_contents("example.com", false, $context);
remember remote host needs allow kind of requests or error
the header() function tried use in example change header send server header('location: http://localhost/samplesite', false);
simple redirect site.
Comments
Post a Comment