Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to include a file
Old 08-13-2007, 07:43 PM How to include a file
dlaroche22's Avatar
Skilled Talker

Posts: 84
Name: Dustin Laroche
Trades: 0
What is the best way to include my database.php file to any other .php files that require a database connection. I know that some ways are more secure then others. I have my database.php in a private folder and just need to know what code would be the best to include it in other .php files. Thanks in advance.
__________________
Under Construction, But A Work In Progress
Webhosting isn't cheap, sponsors are important

Please login or register to view this content. Registration is FREE
dlaroche22 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-13-2007, 08:05 PM Re: How to include a file
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
If the file is required, then using require() should be the solution.

require('path/to/php/file.php');
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-13-2007, 10:58 PM Re: How to include a file
brandrocker's Avatar
Experienced Talker

Posts: 30
Name: CONFIDENTIAL
Location: India
Trades: 0
As suggested above.
Otherwise, use
Code:
include('path/to/php/file.php');
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
brandrocker is offline
Reply With Quote
View Public Profile Visit brandrocker's homepage!
 
Old 08-13-2007, 11:06 PM Re: How to include a file
Mattmaul1992's Avatar
Ultra Talker

Posts: 486
Name: Matt
Trades: -1
Methods and their descriptions

PHP Code:
include('file.php'); 
Includes the file. Does not give a fatal error if include fails but may give a warning.

PHP Code:
require('file.php'); 
Requires that the file is used otherwise it will throw a fatal error.

PHP Code:
require_once('file.php'); 
Doesn't require the same file twice in the same script. This is useful if you want to include config files, etc. that have no need to be required again. I use this more than anything personally.
__________________
PHP Code:
$talkupation++; 

Please login or register to view this content. Registration is FREE
- Free IPB forum hosting (releasing today!!!), no ads, free modifications
Mattmaul1992 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to include a file
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13132 seconds with 12 queries