Alright, I have the following page: mydomain.org/register?referral=iphone_app
I have the following code:
<? $token = 123;
$referral = $_GET['referral'];
$url = $referral.'://account-link?token='.$token;
echo '<a href="'.$url.'">Link your account</a>'; ?>
This code links to the following URL: http://mydomain.org/iphone_app://account-link?token=123
I would like it to link to: iphone_app://account-link?token=123.
How can I fix this?
Would really need to know what $_GET['referral'] contains, or what it should contain, before we can make any educated guesses.
Assuming that it contains the page the user just came from, that value should be expected and you should be able to use preg_match() or explode() to grab what you need (the last bit). Something like...
preg_match($referral, "/^.*/([a-zA-Z0-9_])*$/", $matches);
The fact that it is working directly in the HTML should point to a PHP mistake.