I'm new to PHP and facing a problem when I use require.
- 'Config.php' is in the parent folder
- Model contains test, in which 'LaptopModel.php' is.
- Controller contains the file 'LaptopController.php'
in Config.php:
<?php
$host = "localhost";
$username = "admin";
in LaptopModel.php:
<?php
require '../../Config.php';
in LaptopController.php:
<?php
require '../Model/test/LaptopModel.php';
the question is what the code really is in LaptopController.php when the server process this file? I think about that in 2 ways, that lead to error or not.
<?php
require '../../Config.php';// get the original code from required file
//this cause an error, because from LaptopController.php
//the link to Config.php must be '../Config.php'
or it will be:
<?php
$host = "localhost";
$username = "admin";
//get what was required from Laptopmodel.php file, not the original code