jpgerb
jpgerb

Reputation: 1120

how to simplify includes though out multiple directories

I am using php5.5.

I have multiple directories throughout my domain as well:

domain.com/games/gamename/index.php domain.com/games/gamename/server/databaseconnect.php domain.com/games/gamename/actionone/dosoemthing.php

and many more pages in different directories. I need to include databaseconnect.php on almost every page (but not all). After the page is done doing it's function I have a

header("Location dir/file.php");

I am trying to find a good way to simplify the directories to use something similar to

<base href="domain.com/">

I've tried using

$root = dirname(__DIR__);

and

$root = dirname(__FILE__);

but when I use these it throws a large hyperlink that isn't functional

domain.com/public/cpanel_username/public_html/games/gamename/ with a 404 error.

Any ideas how to simplify both of these?

Thanks!

Upvotes: 1

Views: 34

Answers (1)

Pancake_M0nster
Pancake_M0nster

Reputation: 265

$root = realpath(dirname(__FILE__));

Upvotes: 1

Related Questions