Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-01-2002, 10:23 PM   PM User | #1
skinme!
New Coder

 
Join Date: Jul 2002
Location: London, UK
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
skinme! is an unknown quantity at this point
Function / Constant returning path of current file...

Say the current page is:

http://mysite.com/somedir/go.php

Is there a constant or function that will return a string / contain the path to the file? (in this case "http://mysite.com/somedir/")

Failing that, how can I get to this result?
__________________
skinme.net / v2.php (design nearly completed)
skinme! is offline   Reply With Quote
Old 08-02-2002, 02:19 AM   PM User | #2
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,896
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
This will print out all the variables that PHP has available run it and you will see your options...

PHP Code:
<?
ob_start
();
print_r($GLOBALS);
$str ob_get_contents();
$str=nl2br($str);
ob_end_clean();echo $str;
?>
but I think
echo 'http://'.$HTTP_SERVER_VARS[HTTP_HOST].$HTTP_SERVER_VARS[REQUEST_URI];

will be what you are looking for?

(note 4.02+ & you can do this)
echo 'http://'.$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI];
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Old 08-02-2002, 01:17 PM   PM User | #3
skinme!
New Coder

 
Join Date: Jul 2002
Location: London, UK
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
skinme! is an unknown quantity at this point
That was the beginning of what I needed. I then got rid of the file name:

PHP Code:
<?php
$fullpath 
'http://'.$HTTP_SERVER_VARS[HTTP_HOST].$HTTP_SERVER_VARS[REQUEST_URI];
$thisfile basename($fullpath);
$cutoffpos strpos($fullpath,$thisfile);
$thisdir substr($fullpath0$cutoffpos);
?>
Say the current file is: http://mysite.com/somedir/go.php
$thisdir will contain http://mysite.com/somedir/.

Thanks.
__________________
skinme.net / v2.php (design nearly completed)
skinme! is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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 not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:29 AM.


Advertisement
Log in to turn off these ads.