file_get_contents(),怎么指定行数?

tianyaxiao 2007-07-10 03:48:24
string file_get_contents ( string filename [, bool use_include_path [, resource context [, int offset [, int maxlen]]]] )
这个参数怎么是一个套一个,看不懂?
也没弄成功,怎么指定START和LENGTH
...全文
463 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
tianyaxiao 2007-07-16
  • 打赏
  • 举报
回复
那我要抓取别人网站上的内容还能用什么呢?
gugaga 2007-07-16
  • 打赏
  • 举报
回复
嘿嘿,能够不用 socket 就读取远程数据?
mrshelly 2007-07-16
  • 打赏
  • 举报
回复
......无语.....

啥远程函数,都离不开 fsockopen
aileenguan 2007-07-16
  • 打赏
  • 举报
回复
根据我的使用经验,fsockopen来抓取对方内容的时候才可能有效率问题,这是绝对经过测试的,如果对方服务器有进行一些特殊的设置,这个函数效率会非常低。
gugaga 2007-07-16
  • 打赏
  • 举报
回复
回复人:tianyaxiao() ( ) 信誉:94 2007-7-16 0:53:23 得分:0


?
那我要抓取别人网站上的内容还能用什么呢?

fsockopen 不错,可以使用 http/1.1 能够压缩传输内容,使用的带宽为未压缩的1/3--1/2左右,

mrshelly 2007-07-16
  • 打赏
  • 举报
回复
看你的信誉值就不爽....
curl.
mrshelly 2007-07-12
  • 打赏
  • 举报
回复
http://cn.php.net/manual/zh/function.stream-context-create.php
mrshelly 2007-07-12
  • 打赏
  • 举报
回复
resource context

是一个流句柄...
可以用
Here is an example.

<?php

// Define a context for HTTP.
$aContext = array(
'http' => array(
'proxy' => 'tcp://127.0.0.1:8080', // This needs to be the server and the port of the NTLM Authentication Proxy Server.
'request_fulluri' => True,
),
);
$cxContext = stream_context_create($aContext);

// Now all file stream functions can use this context.

$sFile = file_get_contents("http://www.php.net", False, $cxContext);

echo $sFile;
?>


以指定代理等......

这几个参数与 指定行数无关.... 手册上也说明,一般用 NULL 即可....
tianyaxiao 2007-07-12
  • 打赏
  • 举报
回复
早看过了
手册上没有对参数解释
bool use_include_path [, resource context
这到底是什么东东
mrshelly 2007-07-12
  • 打赏
  • 举报
回复
问问题之前,先去手册看看.... 看手册里有什么不明白的.再发问...

PHP的手册做的蛮好的....
tianyaxiao 2007-07-12
  • 打赏
  • 举报
回复
false, NULL,
分别对应的是什么?
cnhussein 2007-07-12
  • 打赏
  • 举报
回复
mark
caotian2000 2007-07-12
  • 打赏
  • 举报
回复
尽量别用file_get_contents 速度和效率不是很好
caotian2000 2007-07-12
  • 打赏
  • 举报
回复
第三个参数设为NULL即可
mrshelly 2007-07-10
  • 打赏
  • 举报
回复
$url="/test.wmv";
$start=0;
$length=300;
file_get_contents($url, false, NULL, $start, $length);


带[]的意思是参数可选...


可以写为
file_get_contents($url);
file_get_contents($url, false);
file_get_contents($url, false, NULL);
file_get_contents($url, false, NULL, $start);
file_get_contents($url, false, NULL, $start, $length);

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧