fsockopen-is-available-or-not

What is fsockopen? Why it is used?

fsockopen() lets you open an Internet or Unix domain socket connection for connecting to a resource via socket connection. fsockopen() returns a file pointer which may be used together with the other file functions such as fgets(), fgetss(), fwrite(), fclose(), and feof()

Check whether fsockopen is available in your web server programmatically before using it on your code to avoid errors if is not available in your web server.

Following code snippet is a very simple method to check availability in your server.

<?php
if(function_exists('fsockopen')) {
 
echo "fsockopen function is enabled";
 
}else {
 
echo "fsockopen is not enabled";
 
}
?>