URL segments
Last updated: Dec 04, 2023

Introduction

Sometimes it might be handy to know what the value of a certain segment, or all of them, in the url is.

A URL is made out of several segments, for example: https://webigniter.net/documentation/helper-functions/url-segments has 3 segments you can fetch:
1) documentation
2) helper-functions
3) url-segments

Webigniter has a convenient way to access these segments.

Usage

To check one of the segments you can use the getUrlSegment() method in your view files. The parameter (between ( and ) ) specifies which segment you want to use, in this case we want the second segment.

<div class='message'>
   You are watching documentation about <?=$webigniter->getUrlSegment(2);?>.
</div>

<!-- You are watching documentation about helper-functions. -->

If you need to know all of the segments, use the method getUrlSegments().

<div>
   Your current location is <?=$webigniter->getUrlSegments();?>
</div>

<!--  Your current location is documentation/helper-functions/url-segments -->
Table of Contents
  1. Introduction
  2. Usage