(PHP 4 >= 4.3.2, PHP 5, PHP 7)
stream_wrapper_register — ע��һ���� PHP ��ʵ�ֵ� URL ��װЭ��
$protocol
, string $classname
[, int $flags
= 0
] ) : bool�����û�ʵ���Զ����Э�鴦�������������������������ļ�ϵͳ�����У����� fopen()��fread() �ȣ���
protocol
��ע��ķ�װ�����֡�
classname
ʵ����protocol
��������
flags
Should be set to STREAM_IS_URL
if
protocol
is a URL protocol. Default is 0, local
stream.
�ɹ�ʱ���� TRUE
�� ������ʧ��ʱ���� FALSE
��
�� protocol
�Ѿ��д�����ʱ��stream_wrapper_register() ������FALSE
�汾 | ˵�� |
---|---|
5.2.4 |
��� flags ����.
|
Example #1 ���ע��һ�� stream wrapper
<?php
$existed = in_array("var", stream_get_wrappers());
if ($existed) {
stream_wrapper_unregister("var");
}
stream_wrapper_register("var", "VariableStream");
$myvar = "";
$fp = fopen("var://myvar", "r+");
fwrite($fp, "line1\n");
fwrite($fp, "line2\n");
fwrite($fp, "line3\n");
rewind($fp);
while (!feof($fp)) {
echo fgets($fp);
}
fclose($fp);
var_dump($myvar);
if ($existed) {
stream_wrapper_restore("var");
}
?>
�������̻������
line1 line2 line3 string(18) "line1 line2 line3 "