Problem in the require

Asked

Viewed 127 times

-2

This error message is popping me, I don’t know how to fix inserir a descrição da imagem aqui inserir a descrição da imagem aqui inserir a descrição da imagem aqui inserir a descrição da imagem aqui

  • 1

    Wrong way wrong

3 answers

1

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

Basically the constant __FILE__ returns the directory of the file where it was declared (and not of the file where it was included) which in this case would be exemplo_2/class. Then the require would look similar to require "exemplo_2/class/../core/conecta.php". That is from the folder class a directory would be uploaded (it would be inside the example folder), 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 made in relation to the archive index.php (who was the one who included the file usuario_class.php). In that case, playing the require would be require "exemplo_2/../core/conecta.php". That is, in this situation the core folder should be out of exemplo_2.

0

all right?

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’ve helped! ^.^

-1

is to call another right file ?

if you are using require_once

require_once("arquivo_aqui");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.