|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
||||
|
||||
|
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... |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
Quote:
If bypassing this file and I think the rest or part of the file that require this file to be executed will not work. |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
Another way outside of writing custom error handlers is what I do on alot of scripts ->
instead of this PHP Code:
I would do this PHP Code:
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:
__________________
~ 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. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Require()/Include() Question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|