Search code examples
phprequire-once

PHP require_once in back


I have one problem in my code and i dont know how to fix.

I have FILES like that:

ROOT->INCLUDES - inc_files.php

AND NEW FILE

ROOT->INCLUDES->STRANICE - blog.class.php

How can i use require_once in blog.class.php to include inc_files.php ?

My code (blog.class.php)

require_once("./inc_files.php"); 

ALL TRYS

require_once("../inc_files.php"); 
require_once(".../inc_files.php"); 

And more... Please help!


Solution

  • What about using paths relative to your current PHP file?

    In your root/includes/stranice/blog.class.php:

    require_once(dirname(__DIR__) . "/inc_files.php");