Ragavendran Ramesh
Ragavendran Ramesh

Reputation: 358

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');

Upvotes: 0

Views: 289

Answers (2)

Dorvalla
Dorvalla

Reputation: 5240

I am using something simular then that. I am using a p value out of the link to get my page. I pulled out the snippet you are refering too here

$pages_dir = 'inc/content';
include($pages_dir.'/'.$p.'.inc.php');

Upvotes: 2

Riz
Riz

Reputation: 10236

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

Upvotes: 3

Related Questions