HTTP download class code written in PHP _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHP-compiled HTTP download code. Download the http resource class with comprehensive functions and obtain the http header information .? PhpclassDedeHttpDown {public $ m_url; public $ m_urlpath; public $ m_schemehttp; the public function allows you to download the http resource class and obtain the http header information.

  1. Class DedeHttpDown
  2. {
  3. Public $ m_url = "";
  4. Public $ m_urlpath = "";
  5. Public $ m_scheme = "http ";
  6. Public $ m_host = "";
  7. Public $ m_port = "80 ";
  8. Public $ m_user = "";
  9. Public $ m_pass = "";
  10. Public $ m_path = "/";
  11. Public $ m_query = "";
  12. Public $ m_fp = "";
  13. Public $ m_error = "";
  14. Public $ m_httphead = "";
  15. Public $ m_html = "";
  16. // Initialize the system
  17. Function PrivateInit ($ url)
  18. {
  19. $ Urls = "";
  20. $ Urls = @ parse_url ($ url );
  21. $ This-> m_url = $ url;
  22. If (is_array ($ urls ))
  23. {
  24. $ This-> m_host = $ urls ["host"];
  25. If (! Empty ($ urls ["scheme"]) $ this-> m_scheme = $ urls ["scheme"];
  26. If (! Empty ($ urls ["user"]) {
  27. $ This-> m_user = $ urls ["user"];
  28. }
  29. If (! Empty ($ urls ["pass"]) {
  30. $ This-> m_pass = $ urls ["pass"];
  31. }
  32. If (! Empty ($ urls ["port"]) {
  33. $ This-> m_port = $ urls ["port"];
  34. }
  35. If (! Empty ($ urls ["path"]) $ this-> m_path = $ urls ["path"];
  36. $ This-> m_urlpath = $ this-> m_path;
  37. If (! Empty ($ urls ["query"])
  38. {
  39. $ This-> m_query = $ urls ["query"];
  40. $ This-> m_urlpath. = "? ". $ This-> m_query;
  41. }
  42. }
  43. }
  44. // Open the specified URL
  45. Function OpenUrl ($ url)
  46. {
  47. // Reset parameters
  48. $ This-> m_url = "";
  49. $ This-> m_urlpath = "";
  50. $ This-> m_scheme = "http ";
  51. $ This-> m_host = "";
  52. $ This-> m_port = "80 ";
  53. $ This-> m_user = "";
  54. $ This-> m_pass = "";
  55. $ This-> m_path = "/";
  56. $ This-> m_query = "";
  57. $ This-> m_error = "";
  58. $ This-> m_httphead = "";
  59. $ This-> m_html = "";
  60. $ This-> Close ();
  61. // Initialize the system
  62. $ This-> PrivateInit ($ url );
  63. $ This-> PrivateStartSession ();
  64. }
  65. // Obtain the cause of an operation error
  66. Function printError ()
  67. {
  68. Echo "error message:". $ this-> m_error;
  69. Echo "specific return headers:
    ";
  70. Foreach ($ this-> m_httphead as $ k => $ v)
  71. {
  72. & Nb

    Bytes. ? Php class DedeHttpDown {public $ m_url = ""; public $ m_urlpath = ""; public $ m_scheme = "http"; public...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.