and*_*ila 2 php curl file file-get-contents php-parser
我认为这是一个简单的问题,但我已经做了我所知道的但仍然没有工作.我想从这个链接获得输出:
您可以在浏览器上粘贴并查看它.有一些文字输出.我试过PHP中的一些函数,比如file_get_contents和curl.我没有使用ajax或JavaScript,因为我不熟悉它.最后,我正在与XAMPP合作.
小智 7
$url = 'http://api.microsofttranslator.com/V2/Ajax.svc/Translate?text=siapa+rektor+ipb&appId=58C40548A812ED699C35664525D8A8104D3006D2&from=id&to=en';
// using file_get_contents function
$content = file_get_contents($url);
echo $content;
#output# "who is the Rector of the University"
// using file function // read line by line in array
$content = file($url);
print_r($content);
#output# Array (0] => ?"who is the Rector of the University")
// using cURL
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($ch);
echo $content;
#output# "who is the Rector of the University"
Run Code Online (Sandbox Code Playgroud)