The original poster commented:
So what do I put inside the quotes if
home.php
is in the root directory?include '/home.php';
,include 'home.php';
, orinclude '/home'
;?
So what you have here is a base path issue. And without knowing your larger site structure it’s hard to know how to approach. But this is what I suggest you do to make your life easier now & in the future.
First I would recommend using include_once
instead of include
to avoid scenarios where your script might inadvertently attempt to load the same file more than once.
include_once('home.php');
But I would also encourage you to use a base path of some sort to prefix the location of the file so you are not constantly juggling relative locations.
For example, in your main config file, you can define a base path like this:
$BASE_PATH = '/the/path/to/the/codebase/';
Then when you do an include_once
, the syntax would be:
include_once($BASE_PATH . 'home.php');
The benefit of this is no matter how deeply nested your codebase becomes, you will always be anchored to the value of $BASE_PATH
. And your life will be made tons easier thanks to not having to worry about relative path issues.