Is there any function in PHP like that Server.mappath in ASP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fadi
Forum Newbie
Posts: 10
Joined: Wed Mar 24, 2004 1:26 am
Location: Asia:Pakistan

Is there any function in PHP like that Server.mappath in ASP

Post by fadi »

hi
i wan2 know if there is any function in PHP which returns the path of file on any server like that server.mappath(filepath and name) in ASP ?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

how about $_SERVER['PHP_SELF']

Other that may be useful can be found here - http://uk.php.net/reserved.variables

Mark
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Probably you're looking for __FILE__ constant:

Code: Select all

echo __FILE__; // echoes /home/www/yousite.com/yourfile.php
darkforcesjedi
Forum Newbie
Posts: 5
Joined: Sat Mar 27, 2004 1:33 pm

Post by darkforcesjedi »

no, he's looking for realpath

server.mappath returns the absolute path for a directory
server.mappath("/directory/file.php") returns "c:\inetpub\wwwroot\directory\file.php"

the same is the case with realpath; however, this doesn't seem to work with virtual directories
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

virtual-to-real mapping are available in PHP (for current file only) through $_SERVER['PATH_TRANSLATED'] variable
Post Reply