 |
file_get_contents (PHP 4 >= 4.3.0, PHP 5) file_get_contents -- 将整个文件读入一个字符串 说明string file_get_contents ( string filename [, bool use_include_path [, resource context [, int offset [, int maxlen]]]] )
和 file() 一样,只除了
file_get_contents() 把文件读入一个字符串。将在参数
offset 所指定的位置开始读取长度为
maxlen 的内容。如果失败,file_get_contents()
将返回 FALSE。
file_get_contents()
函数是用来将文件的内容读入到一个字符串中的首选方法。如果操作系统支持还会使用内存映射技术来增强性能。
注:
如果要打开有特殊字符的 URL (比如说有空格),就需要使用
urlencode() 进行 URL 编码。
注:
context 参数可以用 NULL 来忽略。
注释警告 | 当使用
SSL 时,Microsoft IIS 将违反协议不发送 close_notify 标记就关闭连接。PHP
将在到达数据尾端时报告 "SSL: Fatal Protocol Error"。要绕过此问题,应将
error_reporting 级别降低为不包括警告。PHP
4.3.7 及更高版本可以在当使用 https:// 封装协议打开流的时候检测出有此问题的
IIS 服务器并抑制警告。如果使用 fsockopen()
来创建一个 ssl:// 套接字,则需要自己检测并抑制警告信息。 |
richard dot quadling at bandvulc dot co dot uk
15-Nov-2005 06:47
If, like me, you are on a Microsoft network with ISA server and require NTLM authentication, certain applications will not get out of the network. SETI@Home Classic and PHP are just 2 of them.
The workaround is fairly simple.
First you need to use an NTLM Authentication Proxy Server. There is one written in Python and is available from http://apserver.sourceforge.net/. You will need Python from http://www.python.org/.
Both sites include excellent documentation.
Python works a bit like PHP. Human readable code is handled without having to produce a compiled version. You DO have the opportunity of compiling the code (from a .py file to a .pyc file).
Once compiled, I installed this as a service (instsrv and srvany - parts of the Windows Resource Kit), so when the server is turned on (not logged in), the Python based NTLM Authentication Proxy Server is running.
Then, and here is the bit I'm really interested in, you need to tell PHP you intend to route http/ftp requests through the NTLM APS.
To do this, you use contexts.
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;
?>
Hopefully this helps SOMEONE!!!
|  |