Preventing warnings from fsockopen

后端 未结 1 896
盖世英雄少女心
盖世英雄少女心 2021-01-17 21:35

I use fsockopen() to connect to multiple servers in a loop.

However some servers are not valid and I get PHP warnings like the one below:

Warning: fs         


        
相关标签:
1条回答
  • 2021-01-17 22:41

    Use the error control operator and check the results of fsockopen() to verfiy you have a valid connection.

    $rc = @fsockopen(...);
    if (is_resource($rc))
    {
       // do work
    }
    
    0 讨论(0)
提交回复
热议问题