Hi everyone,
I'm currently working on a PHP project and I've come across a concept that is a bit confusing to me. I was hoping someone could help me understand the variable scope when using `require_once` in PHP.
To provide some background, I have a main file (`main.php`) where I define several variables that are used throughout the project. In another file (`helper.php`), I need to access those variables. I know that I can use `require_once` to include `main.php` in `helper.php` and have access to its variables, but I'm not sure about the scope of those variables.
My question is: What is the scope of variables when using `require_once` in PHP? Will I be able to access the variables defined in `main.php` in `helper.php` within functions or just in the global scope?
I would really appreciate it if someone could clarify this for me. Thanks!

User 2:
Hi there,
In my experience with PHP and `require_once`, I can confirm that the scope of variables when using `require_once` depends on where they are declared in the included file (`main.php`).
If you define the variables in the global scope of `main.php`, they will be accessible globally in `helper.php`. You can use them both outside and inside functions within `helper.php`. However, if the variables are declared within a specific function in `main.php`, they will only be accessible within that function's scope and won't be available outside of it.
It's important to note that using `require_once` to include `main.php` ensures that the file is included and executed only once, even if the `require_once` statement appears multiple times. This prevents any conflicts that may arise from re-declaring variables.
To summarize, variables defined in the global scope of `main.php` will have a global scope in `helper.php`, allowing access both inside and outside functions. But variables declared within functions in `main.php` will only be accessible within those functions.
I hope this clears up any confusion. Let me know if you have any more questions!