使锟斤拷远锟斤拷锟侥硷拷

只要锟斤拷 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 锟斤拷之前锟斤拷支锟斤拷锟斤拷锟铰猴拷锟斤拷锟斤拷远锟教凤拷锟绞o拷include锟斤拷include_once锟斤拷require锟斤拷require_once 锟皆硷拷GD 锟斤拷图锟斤拷锟斤拷 锟斤拷锟斤拷锟叫碉拷 imagecreatefromXXX 锟斤拷锟斤拷锟斤拷

锟斤拷锟界,锟斤拷锟斤拷锟斤拷锟斤拷锟铰凤拷锟斤拷锟斤拷锟斤拷远锟斤拷 web 锟斤拷锟斤拷锟斤拷锟较碉拷锟侥硷拷锟斤拷锟斤拷锟斤拷锟斤拷要锟斤拷锟斤拷锟斤拷锟斤拷荩锟饺伙拷锟斤拷锟叫╋拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷菘锟侥硷拷锟斤拷锟叫o拷锟斤拷锟竭简单碉拷锟皆猴拷锟皆硷拷锟斤拷站锟斤拷锟斤拷页锟斤拷锟斤拷同锟侥凤拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷★拷

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);
?>

锟斤拷锟斤拷泻戏锟斤拷姆锟斤拷锟饺拷蓿锟斤拷锟揭伙拷锟斤拷没锟斤拷锟斤拷锟捷猴拷某 FTP 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟接o拷锟斤拷锟斤拷锟斤拷锟斤拷锟� 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 锟叫o拷锟斤拷锟杰讹拷锟斤拷锟侥硷拷锟斤拷锟斤拷写锟斤拷锟斤拷锟斤拷锟斤拷锟皆讹拷锟斤拷募锟斤拷丫锟斤拷锟斤拷锟斤拷锟� fopen() 锟斤拷锟斤拷锟侥诧拷锟斤拷锟斤拷锟斤拷失锟杰★拷要锟斤拷锟斤拷锟斤拷锟节分诧拷式锟斤拷志锟斤拷锟铰o拷锟斤拷锟皆参匡拷 syslog() 锟斤拷锟斤拷锟斤拷