歡迎來到小豬圈!

2007-11-30

用 CURL 替代 allow_url_fopen 的限制

  • allow_url_fopen 是用來設定 fopen 是否能開啟 URL,預設值是開啟的,但有資安的問題,建議關閉。
  • 一個替代方案是用 CURL 取代:
    <?php
      $ch = curl_init('http://example.com/');
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      $file_contents = curl_exec($ch);
      curl_close($ch);
      echo htmlspecialchars($file_contents);
    ?>
    

No comments:

Post a Comment

Comment Form Message

標籤分類

Blog Archive

Labels

Google Analytics Tracking Code

About Me

My photo
Keelung, R.O.C, Taiwan
一個不學無術、混吃等死的傢伙…