PHP HttpRequest

前端 未结 3 1663
無奈伤痛
無奈伤痛 2021-01-07 07:59

I need to perform a HTTP GET from PHP.

More specifically, from within /index.php I need to get the content of /trac/ and /svn/, find the \"ul\" element and then ren

相关标签:
3条回答
  • 2021-01-07 08:22

    The simplest way is file_get_contents().

    $str = file_get_contents('http://myserver/svn/');
    
    // Or, if you don't want to hardcode the server
    $str = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . '/svn/');
    
    if ($str)
    {
        // Find the ul
    }
    
    0 讨论(0)
  • 2021-01-07 08:28

    I suggest you have a look at...

    • the HTTP_Request2 PEAR Package,
    • the CURL Library in PHP (if installed) or
    • plain Filesystem Functions in PHP (if you have allow_url_fopen enabled).
    0 讨论(0)
  • 2021-01-07 08:44

    Have a look at file_get_contents - it can be used to open urls under some conditions as can some of the other filesystem functions:

    A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename and List of Supported Protocols/Wrappers for a list of supported URL protocols.

    0 讨论(0)
提交回复
热议问题