ʹ��Զ���ļ�

ֻҪ�� php.ini �ļ��м����� allow_url_fopen ѡ��Ϳ����ڴ������Ҫ���ļ�����Ϊ�����ĺ�����ʹ�� HTTP �� FTP �� URL �������ļ�����ͬʱ��Ҳ������ include��include_once��require �� require_once �����ʹ�� URL��PHP ��֧��Э��ĸ�����Ϣ�μ�֧�ֵ�Э��ͷ�װЭ����

Note:

Ҫ�� PHP 4.0.3 �������İ汾��ʹ�� URL ��װЭ�飬��Ҫ�ڱ���ʱ�� --enable-url-fopen-wrapper ���������� PHP��

Note:

Windows �汾�� PHP 4.3 ��֮ǰ��֧�����º�����Զ�̷��ʣ�include��include_once��require��require_once �Լ�GD ��ͼ���� �����е� imagecreatefromXXX ������

���磬���������·�������Զ�� web �������ϵ��ļ���������Ҫ��������ݣ�Ȼ����Щ�����������ݿ�ļ����У����߼򵥵��Ժ��Լ���վ����ҳ����ͬ�ķ����������ݡ�

Example #1 ��ȡԶ���ļ��ı���

<?php
$file 
fopen ("http://www.example.com/""r");
if (!
$file) {
    echo 
"<p>Unable to open remote file.\n";
    exit;
}
while (!
feof ($file)) {
    
$line fgets ($file1024);
    
/* This only works if the title and its tags are on one line */
    
if (eregi ("<title>(.*)</title>"$line$out)) {
        
$title $out[1];
        break;
    }
}
fclose($file);
?>

����кϷ��ķ���Ȩ�ޣ���һ���û�����ݺ�ij FTP ���������������ӣ���������� FTP �������˵��ļ�����д�����������ø÷����������µ��ļ���������Ը����Ѿ����ڵ��ļ���fopen() �����ĵ��ý���ʧ�ܡ�

Ҫ��"anonymous"������û������ӷ���������Ҫָ���û��������ܻ������룩������"ftp://user:password@ftp.example.com/path/to/file"��Ҳ������ͨ����Ҫ Basic ��֤�� HTTP Э�����Զ���ļ�ʱʹ����ͬ���﷨����

Example #2 �����ݱ��浽Զ�̷�����

<?php
$file 
fopen ("ftp://ftp.example.com/incoming/outputfile""w");
if (!
$file) {
    echo 
"<p>Unable to open remote file for writing.\n";
    exit;
}
/* Write the data here. */
fwrite ($file$_SERVER['HTTP_USER_AGENT'] . "\n");
fclose ($file);
?>

Note:

������Դ����Ϸ����еõ��������øü������洢Զ����־�ļ����������������ᵽ�ģ����� fopen() ��ʽ�򿪵� URL �У����ܶ����ļ�����д���������Զ���ļ��Ѿ������� fopen() �����IJ�������ʧ�ܡ�Ҫ�������ڷֲ�ʽ��־���£����Բο� syslog() ������