What best practices should be followed when closing resources like fsockopen in PHP?

When closing resources like fsockopen in PHP, it is important to properly close the connection to free up system resources and prevent potential memory leaks. This can be done by using the fclose function to close the resource handle after it is no longer needed.

$fp = fsockopen("example.com", 80, $errno, $errstr, 30);
// do something with the socket connection
fclose($fp);