icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » Trying to be more elegant

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old May 28th, 2004, 9:34 AM   #1 (permalink)
Registered User
Seasoned Poster
 
Joined in Jun 2003
30 posts
Gave thanks: 0
Thanked 0 times
Trying to be more elegant

I'm trying to actually write "real" code again and it is harder than I thought (to many years doing nothing but circuit analysis). A quick question. I want to be able to call a php file no matter where I am in my directory strucutre. Lets call the file mainconfig.php. Of course in this file are tons of variables and paths to files and such so I don't have to keep calling them typing /home/specht/html_public/blah/blah/blah/blah in all my source code.

My quesiton is how do I call a base path to my website. This way, no matter where my site goes, I shouldn't have to go through hell to fix it. BTW, i don't plan on leaving surpass any time soon :1openarms I'm just trying to write a bit better code.

-Andrew
specht is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 28th, 2004, 10:29 AM   #2 (permalink)
sam
Surpass Fan
Super #1
 
sam's Avatar
 
Joined in Dec 2003
Lives in NJ
5,057 posts
Gave thanks: 0
Thanked 4 times
take a look at documentation on

$_SERVER["PATH_TRANSLATED"]
$_SERVER["DOCUMENT_ROOT"]

BTW - also you can refer to paths in a relative sense as well

for instance if the file is /home/user/public_html/general/coolstuff/myphp.php

a reference to
general/coolstuff/myphp.php

will work just fine IF - the referring file is in public_html

but you want something more elegant
sam is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

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