my brain is currently soaked and i cant think.
i want to use $_SERVER["SCRIPT_FILENAME"]
to find out the full path the script lies in. but this includes the filename, and i don't want that
how to cut the last "/" (or "\" in windows) and the filename
by easieast way? general for both win & *nix ofcourse
cut last part of a string
Started by Orjan, Nov 07 2008 01:08 PM
8 replies to this topic
#1
Posted 07 November 2008 - 01:08 PM
|
|
|
#2
Posted 07 November 2008 - 01:55 PM
Use dirname(__FILE__) instead. It will show the full root of the file without the filename.
Realize the Web Web services and design.
#3
Posted 08 November 2008 - 11:44 AM
I would do what mikelbring recommended. However, one thing many people do not know about is the DIRECTORY_SEPARATOR constant - it will be \ on windows and / on Linux. So if for some reason, you wanted to accomplish this using string manipulations, you could do:
$string = implode(DIRECTORY_SEPARATOR,
explode(DIRECTORY_SEPARATOR,
$_SERVER['SCRIPT_FILENAME'], -1));
#4
Guest_Jordan_*
Posted 08 November 2008 - 06:07 PM
Guest_Jordan_*
You could also use substr and strrpos:
$path = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos(DIRECTORY_SEPARATOR));
#5
Posted 12 November 2008 - 02:25 AM
that was what John wrote, word by word, do you have something to add that's not someone elses words?
#6
Guest_Jordan_*
Posted 12 November 2008 - 04:51 AM
Guest_Jordan_*
Seems like spam. Deleting/banning.
#8
Posted 14 November 2008 - 01:10 PM
haha ther ewas some jerk who added some annoying thing that Jordan did remove. well, he could have removed my comment to it as well for the flow of the tread...


Sign In
Create Account

Back to top










