PHP - include in subdir not working

2019-07-24 16:10发布

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

1条回答
太酷不给撩
2楼-- · 2019-07-24 16:45

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

查看更多
登录 后发表回答