The question is: How do i insert the variable (echo $url_endpoint;) as a part of the link in the last line: header(\'Location: http://linkhere.com/HERE_I_WANT_THE_VARIABLE\');
header('Location: http://linkhere.com/' . $your_variable);
like this?
<?php
$url_endpoint = get_permalink();
$url_endpoint = parse_url( $url_endpoint );
$url_endpoint = $url_endpoint['path'];
header('Location: http://linkhere.com/'. $url_endpoint);
?>
Try using double quotes and keeping the L
in location
lowercase...
header("location: http://linkhere.com/HERE_I_WANT_THE_VARIABLE");
or for example
header("location: http://linkhere.com/$variable");
No need to concatenate here to insert variables.
<?php
$variable1 = "foo";
$variable2 = "bar";
header('Location: http://linkhere.com?fieldname1=$variable1&fieldname2=$variable2&fieldname3=$variable3);
?>
This works without any quotations.
We can also use this with the $_GET
method
$employee_id = 'EMP-1234';
header('Location: employee.php?id='.$employee_id);
You can add it like this
header('Location: http://linkhere.com/'.$url_endpoint);