简体   繁体   中英

File path for Require / Include PHP

I know this might have been asked before but I can't figure out after reading them posts whats best for my situation. Sorry.

I'm having difficulties in declaring a file path for my include / require_once files.

My folder structure is like this.

 Root folder:
   index.php
   Folder(core)
       init.php
   Folder(user)
       registration.php
       login.php
       logout.php
       ....
   Folder(functions)
       functions.php
   Folder(inc)
       header.php
       footer.php

So the problem I'm having is that every time I try to include or require a file lets say from Folder(core) --> file init.php in Folder(user) -> File registration.php (registration.php would be where the include command be located) it throws me an error and page doesnt load. I get an error "Warning: require_once(/core/init.php): failed to open stream: No such file or directory". Why is this happening? would be same if I try to include other files from different directories.

Please help, I know this might be a silly question but I can't figure out

如果始终先加载index.php并加载其他文件(也可能加载其他文件),则所有内容都相对于根目录:

core/init.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM