0

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?

1 Answer 1

6
$my_path = dirname(__FILE__);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.