佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1254|回复: 14

[PHP] 请问有谁明白吗?

[复制链接]
发表于 16-7-2007 01:02 AM | 显示全部楼层 |阅读模式
Program a function in PHP that sends a HTTP-GET-request.
Analyze the response-code you get and display a proper message.
If the url exists, download the file and parse it for its content-type and all other information you can get from the header.
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 16-7-2007 10:11 AM | 显示全部楼层
需要用到PECL?
回复

使用道具 举报

发表于 16-7-2007 12:16 PM | 显示全部楼层

回复 #2 hui_wooi 的帖子

PECL 让你不用WRITE 你的一些FUNCTION。


http://pecl.php.net/packages.php
回复

使用道具 举报

 楼主| 发表于 16-7-2007 02:21 PM | 显示全部楼层
原帖由 thkee 于 16-7-2007 12:16 PM 发表
PECL 让你不用WRITE 你的一些FUNCTION。


http://pecl.php.net/packages.php

download了php_http.dll。
搬去我.dll的folder。
在php.ini加了extension php_http.dll。
restart我的services。

但是Call to undefined function http_get()
回复

使用道具 举报

 楼主| 发表于 16-7-2007 03:25 PM | 显示全部楼层
是不是我少了什么步骤?
回复

使用道具 举报

发表于 16-7-2007 03:39 PM | 显示全部楼层

回复 #4 hui_wooi 的帖子

Try2
install using pecl command

http://pear.php.net/manual/en/installation.cli.php
回复

使用道具 举报

Follow Us
发表于 16-7-2007 03:42 PM | 显示全部楼层
Introduction to PECL Installations
Downloading PECL extensions
PECL for Windows users
Compiling shared PECL extensions with the pecl command
Compiling shared PECL extensions with phpize
Compiling PECL extensions statically into PHP
http://www.php.net/manual/en/install.pecl.php
回复

使用道具 举报

发表于 16-7-2007 06:25 PM | 显示全部楼层
呵呵 我路过的,
什么是PECL ? 什么用处V
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 16-7-2007 07:19 PM | 显示全部楼层
原帖由 vampcheah 于 16-7-2007 06:25 PM 发表
呵呵 我路过的,
什么是PECL ? 什么用处V

http://pecl.php.net/

[ 本帖最后由 hui_wooi 于 16-7-2007 07:22 PM 编辑 ]
回复

使用道具 举报

发表于 26-7-2008 12:10 PM | 显示全部楼层
LZ!原来这你也跑过来啦!
回复

使用道具 举报

发表于 26-7-2008 02:22 PM | 显示全部楼层
原帖由 hui_wooi 于 16-7-2007 01:02 AM 发表
Program a function in PHP that sends a HTTP-GET-request.
Analyze the response-code you get and display a proper message.
If the url exists, download the file and parse it for its content-type and al ...


fopen 就可以了。
回复

使用道具 举报

发表于 27-7-2008 08:46 PM | 显示全部楼层
原帖由 hui_wooi 于 16-7-2007 10:11 AM 发表 需要用到PECL?
不用啦。
  1. <?php
  2. $buf = <<< EXCERPT
  3. <html><head><title>HTTP Request</title></head>
  4. <body>
  5. <form id="request" method="post" target="#">
  6.   <p>url
  7.   <input id="url" name="url" type="text"/>
  8.   <input type="submit" name="Submit">
  9. </form>
  10. </body>
  11. </html>
  12. EXCERPT;
  13. print $buf;
  14. if ($url = $_POST['url']) {
  15.   printf("<pre><a href="%s">%s</a></pre>", $url, $url);
  16.   httpRequest($url);
  17. }
  18. function httpRequest($url) {
  19.   define ('KB', 1024);
  20.   if ($r = fopen($url, 'r')) {
  21.     print '<p>request headers information:<pre>';
  22.     print var_dump(get_headers($url, 1)).'</pre>';

  23.     while ($buf = fread($r, 1 * KB)) {
  24.       // do whatever...
  25.     }
  26.   }
  27. }?>
复制代码

[ 本帖最后由 黄sir 于 27-7-2008 09:00 PM 编辑 ]
回复

使用道具 举报

发表于 31-7-2008 12:28 AM | 显示全部楼层
<?php
$buf = <<< EXCERPT
<html><head><title>HTTP Request</title></head>
<body>
<form id="request" method="post" target="#">
  <p>url
  <input id="url" name="url" type="text"/>
  <input type="submit" name="Submit">
</form>
</body>
</html>
EXCERPT;
print $buf;
if ($url = $_POST['url']) {
  printf("<pre><a href=\"%s\">%s</a></pre>", $url, $url);
  httpRequest($url);
}
function httpRequest($url) {
  define ('KB', 1024);
  if ($r = fopen($url, 'r')) {
    print '<p>request headers information:<pre>';
    print var_dump(get_headers($url, 1)).'</pre>';

    while ($buf = fread($r, 1 * KB)) {
      // do whatever...
    }
  }
}?>


想请教一下,红色的是用来做什么的?

[ 本帖最后由 Sui_G_G 于 31-7-2008 12:29 AM 编辑 ]
回复

使用道具 举报

发表于 31-7-2008 11:59 PM | 显示全部楼层
原帖由 Sui_G_G 于 31-7-2008 12:28 AM 发表


想请教一下,红色的是用来做什么的?


去 &#160;php.net 打 &#160;echo
你就知道是什么了
回复

使用道具 举报

发表于 1-8-2008 12:44 PM | 显示全部楼层

回复 14# cupid25 的帖子

谢谢。原来是heredoc。现在才懂有这样的东西。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 23-12-2025 10:38 PM , Processed in 0.132133 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表