1. How to disable fsockopen()
The following are two commonly used methods to disable fsockopen.
1. Modify php.ini and add fsockopen after disable_functions =
2. Modify php.ini and change allow_url_fopen = On to allow_url_fopen = Off
2. How to solve the problem that the fsockopen function is disabled
1. If the server does not disable pfsockopen at the same time, directly replace the fsockopen function with pfsockopen.
Specific operation: Search for the string fsockopen( in the program and replace it with pfsockopen(. The example is as follows
Before modification:
$fp = fsockopen($host, 80, $ errno, $errstr, 30);
Modified:
$fp = pfsockopen($host, 80, $errno, $errstr, 30);
2. If the server also disables pfsockopen, use other functions instead, such as stream_socket_client(). Note: The parameters of stream_socket_client() and fsockopen() are different.
Specific operation: Search for the string fsockopen in the program. (Replace with stream_socket_client(, then delete the port parameter "80" in the original fsockopen function and add it to $host. The example is as follows
Before modification:
$fp = fsockopen($host, 80, $errno, $errstr, 30);
After modification
$fp = stream_socket_client($host."80", $ errno, $errstr, 30);
3. What should I do if the PHP version is lower than 5.0, fsockopen is disabled, and there is no stream_socket_client()? Write a function to implement the fsockopen function, reference code: