Codeigniter Retrieving Chargify Return parameters

2019-09-18 06:33发布

问题:

This question already has an answer here:

  • CodeIgniter PHP Framework - Need to get query string 12 answers
  • How can I read a QueryString in CodeIgniter? 3 answers

Using Chargify with Codeigniter framework. On completion of signup with Chargify, the return URL can be set with parameters. It seems that these parameters can only be returned ?id=123&ref=321. With Codeigniter, how do I grab those return paramenters?

http://www.website.com/confirmation?id=3163255&ref=5159c58278a1f

回答1:

CodeIgniter, by default, destroys the $_GET variable that one would usually use to access the parameters in a URL.

This line will parse the URL and populate the $_GET array with the URL's parameters. It's useful for when you want to selectively use the $_GET array in a CodeIgniter project, rather than having to enable CodeIgniter's query strings, which would be globally and continually active.

parse_str(substr(strrchr($_SERVER['REQUEST_URI'], "?"), 1), $_GET);

It can then be accessed as you would normally access an array, for example:

$id  = $_GET['id'];
$ref = $_GET['ref'];