Constants defined in PHP error Use of undefined constant

0

I have a file in the main folder of the project called core.php where I have defined some constants with direct addresses to project folders:

define( "APP_DIR", "app/");
define( "CSS_DIR", "app/css/");
define( "JS_DIR", "app/js/");
define( "IMG_DIR", "app/img/");
define( "LIBS_DIR", "app/libs/");
define( "VIEWS_DIR", "views/");
define( "HTML_DIR" , "views/html/");
define( "ERROR_DIR", "views/error/");
define( "LAYOUT_DIR", "views/layout/");
define( "CONTROL_DIR", "controller/");
define( "MODEL_DIR", "model/");

And from the index I do a require of this file to be able to use it in the whole application, but when I reach a certain point they leave as it were to exist, so to speak, I explain:

I'm going from the index.php that contains code to verify if there is a session or not:

<?php 
require("core.php");

if (!isset($_SESSION['id']) || !isset($_SESSION['tempsess'])) {
    include(CONTROL_DIR . 'CTRindex.php');
}else{
    session_start();
    $newsess = session_id();
    $_SESSION['tempsess'] = $newsess;
    include(CONTROL_DIR . 'CTRindex.php');
}

?>

and hence redirect depending on whether or not there is a controller called CTRindex.php:

<?php 

include(VIEWS_DIR . "html/index.php");

?>

what it does is to call the view already of the index.php with an include so that it shows depending on whether there is a session or not (because of the problem I still do not code that), well everything works perfect, on a label in its href attribute I use one of these constants:

<nav>
    <li><a href="index.php">Home</a></li>
    <li><a href="<?php echo HTML_DIR . 'Contact.php' ?>">Contact</a></li>
</nav>

to call a controller, this has 2 includes using the constants that call a header.php and a footer.php that are general to all the views I have:

<?php  

include(LAYOUT_DIR . "header.php");
//aquí iría contenido
include(LAYOUT_DIR . "footer.php");

?>

but here they are not defined or that's what the error tells me:

This would show the hierarchy of my project:

    
asked by Francisco Castle 01.07.2018 в 07:10
source

0 answers