You Now Here »

[Tutorial PHP] Solution File get contents not working for external URL  (Read 1316 times - 82 votes) 

DANNY

G-Plus Author
  • ADMINISTRATOR
  • More Share Forum Topic
  • [MS] kepala suku
  • *
  • DANNY sangat terkenal!DANNY sangat terkenal!DANNY sangat terkenal!DANNY sangat terkenal!DANNY sangat terkenal!DANNY sangat terkenal!
  • Rep Power: 6
  • Join: September 30, 2009
  • Posts: 11,931
  • Poin: 194.149
    • WWW
  • IP member tracker Logged


beberapa webhosting memungkinkan menggunakan file_get_contents untuk mengambil content dari file lain secara internal maupun eksternal, namun tergantung versi PHP yang digunakan dan konfigurasi server yang diperbolehkan, jika tidak ada solusi, berikut adalah trik untuk menggantikan fungsi file_get_contetns

Code: (file_get_data) [Select]
<?php
function file_get_data($URL){
      
$ch curl_init();
      
curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue);
      
curl_setopt($chCURLOPT_RETURNTRANSFER1);
      
curl_setopt($chCURLOPT_URL$URL);
      
$data curl_exec($ch);
      
curl_close($ch);
      return 
$data;
}
echo 
file_get_data('http://example.com');
?>



semoga bermanfaat dan bisa memberi solusi
terimakasih


View Mobile Web Short URL:
« Last Edit: March 12, 2018, 10:36:31 PM by DANNY »