View Single Post
Old 07-16-2004, 07:03 AM   #4 (permalink)
SinisterMotives
Junkie
 
That construct is most frequently used to test whether a resource handle can be acquired so that your script can determine whether it can perform operations on the handle. For example, the following code would test to see if $fp is a valid file handle:

PHP Code:
if($fp = @fopen('some_file.dat','r')) {
 
fread($fp,filesize('some_file.dat'));
 
fclose($fp);

Prefixing the "@" symbol to a function name suppresses any error message that would be printed if the attempt to acquire a handle failed.
SinisterMotives is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37