PHP If file_get_contents fails, do this instead

后端 未结 7 1838
谎友^
谎友^ 2021-01-02 12:23

I have a function to translate the current text string using the Free Bing translator API. I just want to make sure if anything fails or something happens with the Applicat

7条回答
  •  旧时难觅i
    2021-01-02 13:07

    $translate_feed = file_get_contents('http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=' . BING_APPID . '&text=' . urlencode($text) . '&from=en&to=' . $to_lan . '');
    
    
    if ( $translate_feed === false )
    {
       echo "failed";
    }
    

提交回复
热议问题