Using the url to invoke methods

3rd Mar 19
Thumbnail

I am working on my individual project.  Using the url to determine the methods to call within the controller.

Extract the route

route extraction screenshot of code

1. This will extract the url for example if we visited the page of an individual bird it would be similar to '/bird/read?id=1'.

2. strtok splits a string into smaller strings or tokens passing a delimiter.  In this example the string will be split by the character '?' returning '/bird/read'

3. ltrim php method trims whitespace or any characters passed to it from the beginning of the string.  This will result in 'bird/read' being stored in the variable $route.

I have recently completed my apprenticeship.  I am currently building the API to a React JS site using Firebase.