Reputation: 16017
Although this has been asked a thousand times I still managed to screw things up and not find an answer that serves my issue..
I have 2 files
C:\xampp\htdocs\MF\Pages\ads.php
C:\xampp\htdocs\MF\Pages\ads_view.php
I wanna include ads_view
from ads
what I do is
echo __DIR__;
var_dump(file_exists('ads_view.php'));
and what I get is
C:\xampp\htdocs\MF\Pages
bool(false)
Why can't I include this file when __DIR__
clearly states i'm in the parent folder? ads.php
is also included from another file, if that makes any difference?
Upvotes: 0
Views: 155
Reputation: 2032
You can also use the DOCUMENT_ROOT
variable in $_SERVER for portability.
var_dump(file_exists($_SERVER['DOCUMENT_ROOT'] . '\MF\Pages\ads_view.php'));
and
include $_SERVER['DOCUMENT_ROOT'] . '\MF\Pages\ads_view.php';
Upvotes: 1
Reputation: 45490
Please put the full path it should work
var_dump(file_exists('C:\xampp\htdocs\MF\Pages\ads_view.php'));
see documentation for file_exists
Upvotes: 1