otuatail Posted January 19, 2008 Share Posted January 19, 2008 Can someone tell me of a server variable that returns the file name of the current viewed page please> TIA Desmond. Quote Link to comment https://forums.phpfreaks.com/topic/86753-solved-simple-server-variable-q/ Share on other sites More sharing options...
Aureole Posted January 19, 2008 Share Posted January 19, 2008 I think it's either $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_FILENAME'] Quote Link to comment https://forums.phpfreaks.com/topic/86753-solved-simple-server-variable-q/#findComment-443394 Share on other sites More sharing options...
otuatail Posted January 19, 2008 Author Share Posted January 19, 2008 Thanks $_SERVER['PHP_SELF'] works but it pulls up all the sub folders / directories. Is there a str function to find the last backslash? Sorry Desmond. Quote Link to comment https://forums.phpfreaks.com/topic/86753-solved-simple-server-variable-q/#findComment-443395 Share on other sites More sharing options...
Aureole Posted January 19, 2008 Share Posted January 19, 2008 Try $_SERVER['PATH_TRANSLATED']... I'm pretty sure there is something in the $_SERVER array to do what you want, I just can't remember which one it is! Quote Link to comment https://forums.phpfreaks.com/topic/86753-solved-simple-server-variable-q/#findComment-443397 Share on other sites More sharing options...
Aureole Posted January 19, 2008 Share Posted January 19, 2008 Here's everything in the $_SERVER array... (afaik). $_SERVER['DOCUMENT_ROOT'] $_SERVER['GATEWAY_INTERFACE'] $_SERVER['HTTP_ACCEPT'] $_SERVER['HTTP_ACCEPT_CHARSET'] $_SERVER['HTTP_ACCEPT_ENCODING'] $_SERVER['HTTP_ACCEPT_LANGUAGE'] $_SERVER['HTTP_HOST'] $_SERVER['HTTP_REFERER'] $_SERVER['HTTP_USER_AGENT'] $_SERVER['PATH_TRANSLATED'] $_SERVER['PHP_SELF'] $_SERVER['QUERY_STRING'] $_SERVER['REMOTE_ADDR'] $_SERVER['REMOTE_PORT'] $_SERVER['REQUEST_METHOD'] $_SERVER['REQUEST_URI'] $_SERVER['SCRIPT_FILENAME'] $_SERVER['SCRIPT_NAME'] $_SERVER['SERVER_ADMIN'] $_SERVER['SERVER_NAME'] $_SERVER['SERVER_PORT'] $_SERVER['SERVER_PROTOCOL'] $_SERVER['SERVER_SIGNATURE'] $_SERVER['SERVER_SOFTWARE'] It's obviously not going to be a lot of these, but you could try SCRIPT_FILENAME, SCRIPT_NAME, REQUEST_URI, DOCUMENT_ROOT and maybe one or two others... Hopefully someone will come along and spare you going through all of those... sorry I couldn't be much help. Quote Link to comment https://forums.phpfreaks.com/topic/86753-solved-simple-server-variable-q/#findComment-443398 Share on other sites More sharing options...
otuatail Posted January 19, 2008 Author Share Posted January 19, 2008 Solved but probably the hard way. function filename($val) { $rev = strrev($val); $x = strpos($rev , "/"); $x = 0 - $x; $val = substr($val , $x); return $val; } Quote Link to comment https://forums.phpfreaks.com/topic/86753-solved-simple-server-variable-q/#findComment-443416 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.