tags:

views:

442

answers:

1

Is there a way to achieve the following?

In my /www/var/public_html/index.php file i have this

<?php include('database/connect.php'); ?>

And then in /www/var/public_html/database/connect.php, I want to do something like this

<?php

$my_path = get_path_of_current_script(); // should not be path of index.php
echo $my_path;
// should print
// /www/var/public_html/database
?>

I don't want $my_path to print /www/var/public_html/

Is there a PHP function to do this?

+3  A: 
$my_path = dirname(__FILE__);
Pekka