Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

brianellisrules

macrumors regular
Original poster
OK, this is bad. Really bad. I've been searching online and poking around the internet and haven't found what I need. I have a feeling I'm going to feel like a fool when I see the answer.....

OK, I want to get the file path where the current file is located...

PHP:
$path = $_SERVER['SCRIPT_FILENAME'];
This will kick out the path PLUS the filename. How do I get rid of the filename?
 
sonofslim said:
try $_SERVER["DOCUMENT_ROOT"];

or for a relative path: dirname($PHP_SELF);
I was playing around with $_SERVER["DOCUMENT_ROOT"] before, but that was only giving me up to the root directory... I wasn't aware of dirname($PHP_SELF) before, so that's what I was missing. I ended up using a combination of both:

$path=$_SERVER["DOCUMENT_ROOT"].dirname($PHP_SELF);


Thanks a bunch. I'm just trying to make my latest script a bit more robust.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.