Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help with $_Server variables
Old 08-16-2007, 08:17 AM Help with $_Server variables
Defies a Status

Posts: 1,606
Trades: 0
I am trying to extract a server path including directory from the $_Server Predefined Variables. I seem to be able to get everything except what I want.

$_SERVER['DOCUMENT_ROOT'] yields /home/username/public_html/domain-name
$_SERVER['PHP_SELF'] yields /directory/filename
$_SERVER['SCRIPT_FILENAME'] yields /home/username/public_html/domain-name/directory/filename

What I want returned is /home/username/public_html/domain-name/directory/ Did I miss something somewhere?

If using explode on the 'SCRIPT_FILENAME' is the only option, I sure would appreciate some help on that.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-16-2007, 10:15 AM Re: Help with $_Server variables
Yak Yak Yak Yak Yak

Posts: 593
Location: Rochester, MN
Trades: 0
Could you just use document root, and php self combined?

Something like this: (I don't have my parser, so I can't check this)

$path= $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF'];

You may have to tinker with it, but this should provide what you need.
__________________

Please login or register to view this content. Registration is FREE
neorunner is offline
Reply With Quote
View Public Profile
 
Old 08-16-2007, 11:06 AM Re: Help with $_Server variables
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
PHP Code:
echo dirname($_SERVER['SCRIPT_FILENAME']); 
http://www.php.net/manual/en/function.dirname.php


should output
/home/username/public_html/domain-name/directory/
for
/home/username/public_html/domain-name/directory/file.txt
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 08-16-2007 at 11:08 AM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 08-16-2007, 01:28 PM Re: Help with $_Server variables
Defies a Status

Posts: 1,606
Trades: 0
I appreciate the time you guys took to reply. I don't want the file name.

Quote:
What I want returned is /home/username/public_html/domain-name/directory/
Actually I don't plan to echo the statement at all. I want to do something else with it after I secure it as a variable.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 08-16-2007, 02:20 PM Re: Help with $_Server variables
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Well then, simply don't echo what's returned by dirname()...
PHP Code:
$stuff=dirname($file); 
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 08-16-2007, 03:30 PM Re: Help with $_Server variables
Defies a Status

Posts: 1,606
Trades: 0
I must be denser than a rock today. I never managed to make that work. On that page you linked to, I did find something that works.

Thanks for your help.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help with $_Server variables
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 2.11218 seconds with 12 queries