Jump to content

Code that checks for filename of current page..? No idea where to start


OhEmGee

Recommended Posts

I'm an absolute newbie to php and was wondering if anyone could point me in the right direction, searching google/forums and everywhere else has been no help, I need to excute a peice of code on index.php only, how would I go about doing that..? Using a bit of common sense I'd guess that the code would need to check the current page, then something like an if statement so that if the filename is index.php, the code would work, but display something else if not. I hope that made sense!

Well I read the manual but none of it helps with what I'm trying to do, I tried this but it obviously doesn't work,

 

<?php

$index = "absolute/path/to/my/index.php"

if ( __FILE__ == $index ) {

  include("certain_file.php");

  }

?>

 

but I hope that makes it clearer for what I am trying to get. I'd like the code to check if the file is index.php and if so, then include the certain file.  ??? ??? Sorry I am still learning Php, it's difficult reading that manual because it's like I've been thrown into the deep end, I don't yet know how it all works.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.