Display path to current directory

Both of function display for current directory. <?php echo __DIR__."<br/>"; ?> or <?php $path = getcwd(); echo $path; ?>

2 Responses

You can also use:

$path = shell_exec('dir'); // windows
// or
$path = shell_exec('pwd'); // linux
// or
$path = `dir`; // windows
// or
$path = `pwd`; // linux

echo $path;

... but, you should use the magic constant of __DIR__ if the version of PHP
@Frank Pennock ... supports it (sorry, hit enter on accident). The reason being that a constant already created is faster than any function or command line call. Waaaay faster.

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.