Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Include Files and Classes

Status
Not open for further replies.

Michael42

Programmer
Joined
Oct 8, 2001
Messages
1,454
Location
US
I have a file that contains my Application class. I want to have an include file that will make it easier to set the instance variables. So I made an include called config.php.

I use includes for other things (headers\footers) so I think I have the syntax right:
include 'config.php';

If I move my code to the include with my instance variables and create an include directive to it from the page with my classes it does not work. Blank screen etc.???

What can you recommend?

Thanks,

Michael42
 
>> What have you done to test?

Bascially just move the code back and forth between being in my file that houses my Application class and to my config.php include file.

Instance variable declarations seem to only work when not in an include.

Thanks for the response,

Michael
 
Hey maybe this is it. My include file with class instance variables is at a second tier, i.e., it represents an include file that has an include.

Is that OK in PHP?

 
>>Included files and themselves include files.
Is this cool in PHP?


I tried <?...?>, <?php...?> and none at all.
No joy. :-(

Thanks for the suggestion though,

Michael42
 
Sorry, I got my grammar messed up.

Yes, it's all right for an included file to itself include another file.

If you're included file contains code, you're going to need <?php...?> tags as appropriate. An included file reverts PHP's interpretation back to HTML mode.


Have you viewed the source of the HTML produced? There might be something in there that can give you a clue, but malformed HTML tags are preventing you from seeing it on the browser.

What is your error_reporting setting? There might be an error that PHP has been told to not report.

Are you making use of the &quot;@&quot; error-suppression operator? That could be preventing errors from being displayed.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
shouldn't it be

include('config.php');

?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top