Home >Backend Development >PHP Tutorial >Solution to disabling virtual host php fsockopen function
After modification:
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 and replace it 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 fixing:
After modification
3. If the PHP version is lower than 5.0, fsockopen is disabled, and there is no What to do with stream_socket_client()? Write a function yourself to implement the function of fsockopen, reference code:
Specific operations: 1. First find the code segment that uses the fsockopen function, add the above code to the top of it, and search for the string fsockopen( in the code segment and replace it with b_fsockopen(. 2. Because the fsockopen function returns the file pointer, it can be operated by the file function. However, the b_fsockopen function fails to return the file pointer. You need to continue to modify the code segment: replace fread( with socket_read(, replace fwrite( with socket_write(, use socket_close( Replace fclose(. |