Home > php教程 > php手册 > PHP 文件操作类创建文件并写入

PHP 文件操作类创建文件并写入

WBOY
Release: 2016-06-13 09:33:14
Original
794 people have browsed it

   if (! empty ( $mode )) {

  $this->mode = $mode;

  }

  //判断写入的内容

  if (! empty ( $content )) {

  $this->content = $content;

  }

  $handle = fopen ( $this->path, $this->mode );

  //拆分换行

  $string = explode ( ",", $this->content );

  foreach ( $string as $v ) {

  fwrite ( $handle, $v . "\r\n" );

  }

  fclose ( $handle );

  }

  }

  //使用

  $log = new log ();

  // $log->addlog (); //不传值 走默认值

  // $log->addlog ( "./log", "a", " 内容1:$content1 内容2: $content2 内容3: $content3 " ); //传多个内容

  // $log->addlog ( "./log", "a", "123,123,123" ); //一次插入并换行

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template