Tree:
--myproject
----mailer
-------class.phpmailer.php
----test
-------index.php
----site.php
----class.php
----db.php
----index.php
index.php: (both)
<?php
require_once '../site.php';
?>
site.php:
<?php
require_once "class.php";
?>
class.php
<?php
require_once 'db.php';
require_once('./mailer/class.phpmailer.php');
?>
When I visit test it shows:
Warning: require_once(./mailer/class.phpmailer.php): failed to open stream: No such file or directory in C:\wamp\www\myproject\class.php on line 3
Fatal error: require_once(): Failed opening required './mailer/class.phpmailer.php' (include_path='.;C:\php\pear') in C:\wamp\www\myproject\class.php on line 3
I also tried include_once but same error!
You're calling the
From inside index.php, so the file is two levels above.
Change
to
UPDATE
Just realized you need both index.php files working. It's not the prettiest solution, but you can do it like this:
/test/index.php
/index.php
This new "nested" variable will determine if the file is inside a directory or on the base.
Edit your class.php to look like this:
This should fix the problem in both files.