Problem does not require [closed]

-2

This error message is appearing to me, I do not know how to solve it

    
asked by anonymous 03.02.2018 / 18:30

3 answers

1

In the usuario_class.php file, on line 2, change require "../core/conecta.php" to require __FILE__ . "/../core/conecta.php" .

Basically, the constant __FILE__ returns the directory of the file where it was declared (and not the file where it was included), in which case it would be exemplo_2/class . Then require would be similar to require "exemplo_2/class/../core/conecta.php" . In other words, from the folder class would be a directory (would be inside the folder example_2), and it would be possible to access the core folder.

The same does not happen in the original require ( require "../core/conecta.php" ) because the relative paths are done relative to the file index.php (which was who included the file usuario_class.php ). In this case, when interpreting require would be require "exemplo_2/../core/conecta.php" . That is, in this situation the core folder should be out of example_2.

    
03.02.2018 / 18:52
0

Alright?

To avoid these conflicts, use the PHP array information: DOCUMENT_ROOT! This variable will return the main path of the WWW / HTDOCS / WEB server

Example:

<?php
$_DIR = $_SERVER['DOCUMENT_ROOT'];
require_once "$_DIR/assets/server/configuration.php";
?>

I hope I have helped! ^. ^

    
04.02.2018 / 05:21
-1

Is it to call another file right?

if you use require_once

require_once("arquivo_aqui");
    
03.02.2018 / 18:54