Search code examples
phpincludeinclude-path

How to include php db config file form sub directory


I want to use this database config file which located in-> "/main/config.php" directory. Now please tell me how can i include that config.php from-> "/main/admin/login.php" file.

i have simply tried following but not worked-

<?php 
include "/main/config.php";
?>

thanks in advance


Solution

  • If you are trying to go back to the file directory then this will include the file. However you have missed the brackets.

    <?php include("../main/config.php"); ?>