ホームページ  >  記事  >  バックエンド開発  >  PHP_PHP チュートリアルで書かれた HTTP ダウンロード コード

PHP_PHP チュートリアルで書かれた HTTP ダウンロード コード

WBOY
WBOYオリジナル
2016-07-13 17:41:17852ブラウズ

比較的充実した機能を備えたhttpリソースクラスをダウンロードし、同時にhttpヘッダ情報を取得します。

    class DedeHttpDown
  1. {
  2. public $m_url = "";
  3. public $m_urlpath = "";
  4. public $m_scheme = "http";
  5. public $m_host = " ";
  6. public $m_port = "80";
  7. public $m_user = "";
  8. public $m_pass = "";
  9. public $m_path = "/";
  10. public $ m_query = "";
  11. : //初期化系统
  12. function PrivateInit($url )
  13. {
  14. $urls = "";
  15. $urls = @parse_url($url);
  16. $this->m_url = $url;
  17. if(is_array($urls))
  18. {
  19. $this->m_host = $urls["host"];
  20. if(!empty($urls["scheme"])) $this->m_scheme = $urls["scheme"];
  21. if(!empty($urls["user"])){
  22. $this->m_user = $urls["user"];
  23. }
  24. if(!empty($urls["pass "])){
  25. $this->m_pass = $urls["pass"];
  26. }
  27. if(!empty($urls["port"])){
  28. $this-> ;m_port = $urls["ポート"];
  29. }
  30. if(!empty($urls["path"])) $this->m_path = $urls["path"];
  31. $this->m_urlpath = $this->m_path;
  32. if(!empty($urls["query"]))
  33. {
  34. $this->m_query = $urls["query"];
  35. $this->m_urlpath .= "?" .$this->m_query;
  36. }
  37. }
  38. }
  39. //打开指定网址
  40. function OpenUrl($url)
  41. {
  42. // 重设各パラメータ
  43. $this-> m_url = "";
  44. $this->m_urlpath = "";
  45. $this->m_scheme = "http";
  46. $this->m_host = " ";
  47. $this->m_port = "80";
  48. $this->m_user = "";
  49. $this->m_pass = "";
  50. $this->m_path = "/";
  51. $this->m_query = "";
  52. $this->m_error = "";
  53. $this->m_httphead = "" ;
  54. $this->m_html = "";
  55. $this->Close() ;
  56. //初化系统
  57. $this->PrivateInit($url);
  58. $this->PrivateStartSession();
  59. }
  60. //获得特定の操作错误の原因
  61. function printError ()
  62. {
  63. echo "错误情報:".$this->m_error;
  64. echo " 具体的な返头:
    ";
  65. foreach($this->m_httphead as $k=> ;$v)
  66. {
  67. &nb

    www.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/486141.html技術記事 ?php class DedeHttpDown { public $m_url = "";パブリック $m_urlpath = "";パブリック $m_scheme = "http";公開...
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。