General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old January 13th, 2003, 10:05 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Require()/Include() Question

Okay, i'm going to try and explain this as best I can... Talking to a friend earlier, I made it much more confusing that it really should be... =)

Obviously, include() will include and evaluate a specified file... but what happens if that file doesn't exist... you get an error like this:
Fatal error: Failed opening required '_footer.php' (include_path='.;c:\php4\pear') in e:\pub\public_html\temp_list.php on line 52

Is it really necessary for an end user to see the entire path of the file? Is there any way to block that from coming up... maybe so it just says something like ../temp_list.php?

Any suggestions are welcomed...

Reply With Quote
  #2  
Old January 13th, 2003, 10:18 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
If the file may not possibly exist, you can susspend the error by placing a @ at the front of the function, for example:

@include("file_does_not_exist.php");

becuase the @ symbol is in front of the function, if the function returns a error message, it will not be displayed to the user.

Reply With Quote
  #3  
Old January 13th, 2003, 11:22 PM
wareseeker wareseeker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 71 wareseeker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 7 sec
Reputation Power: 6
Quote:
If the file may not possibly exist, you can susspend the error by placing a @ at the front of the function


If bypassing this file and I think the rest or part of the file that require this file to be executed will not work.

Reply With Quote
  #4  
Old January 14th, 2003, 02:32 AM
Lindset Lindset is offline
weirdomoderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Alta, Norway
Posts: 370 Lindset User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Lindset Send a message via AIM to Lindset
You can write a custom error handler.. Read more about it in the manual: http://www.php.net/manual/en/functi...ror-handler.php
__________________
Best Regards,
Håvard Lindset

Reply With Quote
  #5  
Old January 14th, 2003, 06:05 AM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 6
Another way outside of writing custom error handlers is what I do on alot of scripts ->

instead of this
PHP Code:
include( 'config.php' );
include( 
'dbconn.php' ); 

I would do this
PHP Code:
/************************************
Initialize scalar
************************************/
$_ec = ( bool ) false;
/************************************
Include files or bind errors
************************************/
if ( !@include( 'config.php' ) ) $_ec .= 'Failed to including config.php.';
if ( !@include( 
'dbconn.php' ) ) $_ec .= 'Failed to including dbconn.php.'

Now, when the if executes, it will try to include the file into the namespace, if it does, all is good; if it does'nt, it will bind the message to the $_ec scalar. After that, its pretty trivial from there in what to do to display your page appropriatly. Example ->
PHP Code:
if ( $_ec ) {
/* Error is bound - do whatever ( redirect, email error, etc. ) */
}
else {
/* Error is not bound - files included, finish page execution */

__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Require()/Include() Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway