I am currently attempting a 404 report system.
If a 404 occurs then details are INSERT'd into a MySQL table. The entry of information is not the problem, however.
I want to determine what the EXACT file name is.
I know I can explode the $_SERVER['HTTP_REFERER'] variable, then only echo the specific array element, but what if I coded this to find the file after one sub-folder and the page is actually 2 sub folders, for example:
1 sub folder
domain.com/tutorials/one.php
If I coded the page to retrieve the third array element of this exploded, I would get 'one.php' returned.
But what if the user clicks on a file say
domain.com/tutorials/further/blah.php
Then the third array element would no longer be the page name + ext but it would now be 'further' which isn't what I want.
What I want
Is there a way of grabbing the very last array element regardless of what it is?
Why I want this
I want to save to the 'error' table what the page was that the user clicked on to be faced with a 404.php page.
Thank you for your time 🙂