如何用php包含绝对路径

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

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

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