Jump to content

includes


topcoder1

Recommended Posts

I have 3 files Index.php, x.php and  login/Login.php

in Login.php

<?php require_once "../x.php"; ?>

 

Index.php

<?php require_once "login\Login.php"; ?>

 

when executing Index.php error is Failed opening required '../x.php'

I can of course say <?php require_once "x.php" ?> in Login.php, then Index.php would load fine.. However if I load login\Login.php independently, x.php would not be found.

 

So what should I do?

 

 

Link to comment
https://forums.phpfreaks.com/topic/67128-includes/
Share on other sites

Best to use absolute paths, you can use $_SERVER['DOCUMENT_ROOT'] as a starting point.

 

thanks but if I create a config.php that sets my app file root, then I need to include that config.php as well... this problem becomes circular.. might as well put everything under the app root...

there has to be a simple solution right?  I searched for a while and not able to find one...

Link to comment
https://forums.phpfreaks.com/topic/67128-includes/#findComment-336773
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.