1

This is what I have

site.com/user/filehere.php

I need to go to

site.com/user/messages/index.php 

the index.php is

<?php 
include_once("../filehere.php");
?>

The problem is that inside filehere.php

there is another includes like

filehere.php

<?php  

include_once("../menu.php); 

?>

and these includes are not reconized in the /messages dir even when it's all ok when I acess directly the included file

LF00
  • 27,015
  • 29
  • 156
  • 295
Otávio Barreto
  • 1,536
  • 3
  • 16
  • 35

1 Answers1

2

add __DIR__ to your file path to represent the current php dir. For more refer to this post.

Community
  • 1
  • 1
LF00
  • 27,015
  • 29
  • 156
  • 295
  • same problem with subdir it shows the page ok but the includes in the page are not displayed – Otávio Barreto May 11 '17 at 13:57
  • 1
    Today I also encountered this, I solve it by specify the absolute path. For example, I use laravel, I use app_path() . '/services/aaa.php' – LF00 May 11 '17 at 14:00
  • 1
    I am making this in pure php so I will have to change all includes in the site – Otávio Barreto May 11 '17 at 14:06
  • 1
    May be you can wrote a simple autoloader for your php files, which will save a great work. May be there are other include way. Wait for some expert to answer it. – LF00 May 11 '17 at 14:09
  • I think I will change one by one with `include_once ( $_SERVER['DOCUMENT_ROOT'].'/site/user/file.php');` I will see what I will implement – Otávio Barreto May 11 '17 at 14:14