I am trying to set-up a structure for my application to properly include scripts across various pages and subdirectories
The issue I am having;
inside my index.php I have
define ('BASE_URL', 'http://localhost/cformv2/');
include BASE_URL . 'inc/functions.php';
require BASE_URL . 'inc/db.php';
include BASE_URL . 'inc/auth.php';
and inside my functions.php I have
$hello = 'hi';
When I call echo $hello;
in the index page, it will give me a notice saying;Notice: Undefined variable: hello in
If I echo $hello in functions page, the message appears in the index page.
After trying to fix, I noticed that, If I move functions.php to the same directory and use include ('function.php');
and echo $hello
in the index page, it works. So I assume, I am using this BASE_URL incorrectly.
In summary, what am I trying to do is to be able to include files without manually entering the path each time, after reading a couple of posts, I started using this option using DEFINE ();. Currently, all of my works are in folder cformv2 and working on localhost. Once it finishes, it will be uploaded to my web host. I have multiple files in multiple folders under this base directory (cformv2).
How can define the path to this folder so that I can include my other files from other folders? Also, how it is that I can include the file and not able to call the variable or a function within it?
Thanks in advance.