Saracoglu
Saracoglu

Reputation: 37

File address of the server

How to find the address of the server that contains the files?

for example:

/home/hosting/helloworld/public_html/

Is it possible to print it with PHP?

Upvotes: 0

Views: 66

Answers (5)

bkilinc
bkilinc

Reputation: 989

echo __DIR__; 

will print the directory of the running script

Upvotes: 0

Bora
Bora

Reputation: 10717

Use dirname your root index.php file.

echo dirname(__FILE__);

Or in PHP 5.3+

echo __DIR__;

Upvotes: 1

Hanlet Escaño
Hanlet Escaño

Reputation: 17380

Also if you pass a filename you can use this one:

echo realpath("sample.php");

in my case it prints:

D:\Hosting\232325443\html\sample.php

Upvotes: 0

m1k1o
m1k1o

Reputation: 2364

This will get current server path.

echo getcwd();

http://php.net/manual/en/function.getcwd.php

Upvotes: 0

Alma Do
Alma Do

Reputation: 37365

I guess you're looking for

$_SERVER['DOCUMENT_ROOT']

Upvotes: 1

Related Questions