Robert Glavaš Robert Glavaš - 2 months ago 16
PHP Question

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!

Answer

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");
Comments