Recently I had a problem identifying the current page.
I was using __FILE__
to get the current file, and used substr()
to get the string after the last occurrence
of bars, it turns out that on some operating systems these bars work differently and end up not returning the name as expected.
Is there any function / variable that already returns the file name?
What I currently use:
echo substr(__FILE__, strrpos(__FILE__, '\') + 1, -4);
Used before:
echo substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '/') + 1, -4);
I learned now:
echo basename($_SERVER['PHP_SELF'],'.php');