Search code examples
phpinclude-path

how to add absolute path with php include


I am adding a absolute path with the php include.

$path ="/";

instead of include('../connect.php');

i want to include like include($path.'connect.php');

Solution

  • If you are using any framework, then follow that, otherwise you can do following:

    $path = __DIR__;
    include($path . '/connect.php'); // change this to match path