Andreas2003 Posted June 26, 2009 Share Posted June 26, 2009 Hi there, got a small problem: I have to set a variable, but case-sensitive. The first case is, when the main site of oscommerce "index.php" is being displayed. The other case is, when the product page "product_info.php" is being displayed. How can I find out, what the current site/page/filename is ? Can I use something around $_SERVER["HTTP_HOST"] or $_SERVER["REQUEST_URI"] or something like that ? $SERVER["SCRIPT_FILENAME"] brings up the filename, but the whole path is included. I only need the filenname. How can I handle that? Thanks for your help Regards Andreas Update: sorry, posted too quickly. Found the solution and managed it with $_SERVER["SCRIPT_NAME"] Link to comment Share on other sites More sharing options...
germ Posted June 26, 2009 Share Posted June 26, 2009 Another method: switch ( basename($PHP_SELF) ) { case FILENAME_DEFAULT: /* code for action on index.php */ break; case FILENAME_PRODUCT_INFO: /* code for action on product_info.php */ break; default: /* code for action if no other cases are matched */ } If you only have two possibles an "if ... else" is great. For more than that I always use the "switch". :) If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.