PHP-Written HTTP download class Code _php tutorial

Source: Internet
Author: User
Tags php class
The function compares full download HTTP resource class, at the same time can obtain the information of HTTP header.
  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. Initializing 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 each parameter
  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. Initializing the system
  62. $this->privateinit ($url);
  63. $this->privatestartsession ();
  64. }
  65. Get the cause of an operation error
  66. function Printerror ()
  67. {
  68. echo "error message:". $this->m_error;
  69. echo "Specific return header:
    ";
  70. foreach ($this->m_httphead as $k = $v)
  71. {
  72. &nb

    http://www.bkjia.com/PHPjc/486141.html www.bkjia.com true http://www.bkjia.com/PHPjc/486141.html techarticle the function compares full download HTTP resource class, at the same time can obtain the information of HTTP header. 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.