Using a variable

Hi there,

I’m looking to do the following:

$this->redirect('external-url.com/index.php?userid=$userid');

However, when the redirect takes place, it just writes userid=$userid rather than pulling in the actual user id from my app.

Any help?

Thanks

Hi,
Try this:


<?php
$this->redirect('external-url.com/index.php?userid=' .$userid. '');
?>

or this:


<?php
$this->redirect("external-url.com/index.php?userid=$userid");
?>

Thanks,
Kevin

If you are using single quotes then the variable will be read as a $value so you would need to come out of the quotes to put the value.


$this->redirect('external-url.com/index.php?userid='. $userid);

or use double quotes


$this->redirect("external-url.com/index.php?userid=$userid");

which will parse the value

Thank you, Spike for catching that.

Awesome, thank you!! worked a charm :slight_smile: