Answer the question
In order to leave comments, you need to log in
How does include/require actually work in PHP?
How does everything really happen? What are the scopes? Does it depend on the nesting of files in the system? Do scopes depend on "nesting" include/require? Does include/require affect .htaccess
Let's say I include Config.php from the index page, which is located in ./core
Config.php includes files from core
Then I include modules ./customer/index.php or /admin/index from the index page .php
And I'm constantly faced with the unavailability of any variables, methods and even classes
. And no logic can be traced
. How does it all really work? How to connect modules correctly?
UPD 1
File structure:
/root
---index.php
---action.php
---/core
------config.php
------core.php
------utils.php
---/customer
------index.php
------action.php
core/config.php
<?
require_once "core.php";
require_once "utils.php";
?>
<?
require_once "utils.php";
?>
<?
function prepare_db_val()
{
...
}
?>
<?
require_once "core/config.php";
if( isset($_GET['act']))
{
require_once "action.php"; // не работает
require_once "customer/index.php"; // работает!
}
?>
<?
if( isset($_GET['act']))
{
require_once "action.php";
}
?>
<?
$db_q = prepare_db_val($_GET['val']);
?>
Answer the question
In order to leave comments, you need to log in
How does everything really happen?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question