[]$body = ereg_replace( $value, $fileurl, $body )

WBOY
Release: 2016-06-13 12:43:38
Original
856 people have browsed it

[求助]$body = ereg_replace( $value, $fileurl, $body )

function remoteimg($imgurl) {<br />
    import('@.ORG.Session');//不在文件头部需包含Session<br />
    $mid = Session::get('mid');//获取mid<br />
    //文件保存目录路径<br />
    $imgPath = "/Uploads/$mid".date( 'Ymd' ).'/files/';//当前日期文件夹url<br />
    dir_create($imgPath);//创建这个目录<br />
    //文件保存目录URL<br />
    $imgUrl = __ROOT__.'/'.  $imgPath;//取当前文件下配置的root参数值<br />
    set_time_limit( 0 );//代码执行时间限制,为0无限制知道程序执行完毕<br />
    $milliSecond = date( "dHis" ) . '_';//记录当前的日期时间分数秒数<br />
    if ( !is_dir( $imgPath ) ) @mkdir( $imgPath, 0777 );//目录不存在则创建目录(完全权限)<br />
    $value = trim( $imgurl );//去除图片地址两头的空格<br />
    $get_file = @file_get_contents( $value );//获取图片数据<br />
    $rndFileName = $imgPath.$milliSecond.$key.'.'.substr( $value, -3, 3 );//在当天图片路径下生成文件路径 ????$key????<br />
    $fileurl = $imgUrl.$milliSecond.$key.'.'.substr( $value, -3, 3 );//在root路径下生成文件路径<br />
    if ( $get_file ) {//如果已经取得文件<br />
      $fp = @fopen( $rndFileName, 'w' );//创建路径、文件<br />
      @fwrite( $fp, $get_file );//写入图片数据<br />
      @fclose( $fp );//关闭写入数据流<br />
      $body = ereg_replace( $value, $fileurl, $body );//检查$body中是否有与value匹配的字符串,有的话用fileurl替换掉<br />
    }<br />
    echo $body;<br />
}
Copy after login

如题:谁能解释下这个方法的功能是什么?
$body的用法是什么意思?

php 变量 ereg_replace
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template