The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Should I use any error-checking when connecting to remote URL?
I have a hack (the Forum News hack) which uses file() to connect to a remote file to read it:
PHP Code:
Right now, there is nothing in place to do anything about it if that remote file can't be found or connected to. It's possible that the remote server might go down, or the path or file name could be changed, or something else. What happens if this PHP function, file(), can't get the remote file? Should I somehow check to see if the remote file can be connected to first, before the rest of the code tries to run? If so, how? Would @file() do anything? |
#2
|
||||
|
||||
If you don't care what the error is, use this:
Code:
$data = @file($filename); if ($data !== false) { $data = implode('', $data); } else { // it failed } |
#3
|
||||
|
||||
What would happen if I don't use that, and the script can't connect to the remote file?
|
#4
|
||||
|
||||
file() will return false and issue a notice. (or a warning, either one)
(is it that hard to test file('http://www.this.com/leads/to/no.where');?) |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|