Reputation: 5554
I have the following code inside the body of my index.php page:
echo "Begin <br />";
include('test.shtml');
echo "Importing dbRead.php here <br />";
include(dirname(__FILE__) . '/dbRead.php');
echo "We have included dbRead.php here <br />";
The output on the page is:
Begin
Inside test.shtml
Importing dbRead.php here
The files are all in the same directory. What's going on?
EDIT: dbRead.php is a class. It is parsed just fine by my WAMP server, but not the web server after I upload. It contains a single class with properly formed methods and a constructor.
Upvotes: 1
Views: 3348
Reputation: 15892
Based on your output the issue isn't the include
s (btw, dirname(__FILE__)
is unnecessary unless the file itself (index.php) is also included by another file)... the issue is you have an error in dbRead.php
or it doesn't exist, or it stops further execution (with exit
die
etc).
Does your DIR look like:
/
/index.php
/test.shtml
/dbRead.php
?? Or are you expecting the dirname(__FILE__)
to shift the directory in some way?
Upvotes: 1
Reputation: 137420
As far as I see all the echos are executed before include(dirname(__FILE__) . '/dbRead.php');
, but no echo output is visible after that. There are some possibilities, for example:
dbRead.php
you use for example ob_start();
(see documentation), thus the echo is executed, but not sent to the browser,dbRead.php
, but you have error reporting turned off (see documentation),exit
(see documentation) or die()
(see documentation) within the included file,Upvotes: 3