History


Get

Get returns the URL of the current page or the specified number of pages back in the history.

Parameters

Get has two optional parameters that it accepts.

Name Type Description Default
Pages Integer The number of pages back into the history. 0
As Array Boolean If set to TRUE, will return an array of the history, from the oldest page, up to the current page or the specified number of pages back in the history. FALSE

Return

Get has two possible types of values it returns, depending on the parameter values supplied.

Examples

Retrieve the URL of the current page.

$url = $this->history->get();

This is identical to:

$url = $this->history->get(0);

To retrieve the URL of the previous page, we look 1 page back.

$url = $this->history->get(1);

Obviously it's easy to go from there and know that supplying 2 will get the URL 2 pages back into the history and so on.

If for some reason you wanted it get an array, you can do:

$array = $this->history->get(3, TRUE);

This will give you an array containing the oldest page in the history up to the specified number of pages back, which in the above case is 3 pages back. I doubt you'll need to get an array very much, if at all, since this is primarily for internal use by History.