dos php incluye en diferentes ubicaciones
Frecuentes
Visto 55 equipos
1
I have files segmented into different parts first is the config.inc.php which is located in the root dir, the second is inc/header.inc.php. When I designed the index everything worked well, but now I am starting on the first page which is located in about/index.php and everything loads with the exception of the config.inc.php I have been searching for a solution for over a hour with no luck at all. Do I just need to call the config in the about/index.php or am I missing something here all together.
I tried several solutions already involving the SERVER and getcwd(), but nothing worked.
Here is what the header.inc.php looks like
<?php
/*
* This requires the call of the config file for the website
*/
include './config.inc.php';
/*
* Any addition includes or script code goes below this line
*/
?>
<!DOCTYPE html>
0 Respuestas
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas php or haz tu propia pregunta.
If you put in many files later when the project grows, you run into more and more trouble. 2 suggestions: Make the requested files always start from 1 file in the root directory:
/all_request_start_here.php
aka/bootstrap.php
. From this point you include the contents, helpers, config etc. Second suggestion is to make use ofSPL_autoload
and wrap all the stuff into cool objects. - Daniel W.try include '../config.inc.php'; - Rakesh Sharma
@RakeshSharma I did try that and it broke the core index page and didn't fix the about/index.php :\ DanFromGermany I will have to research that tomorrow when I get home from work I am at the verge of exhaustion and I still have to write a document before getting sleep. - NathanJ2012
better you have a define('BASEURL','your site url'); in common file and access all files with that - Rakesh Sharma