加入收藏 | 设为首页 | 会员中心 | 我要投稿 平凉站长网 (https://www.0933zz.com.cn/)- 图像处理、语音技术、媒体智能、运维、低代码!
当前位置: 首页 > 站长百科 > 正文

PHP静态文件生成类

发布时间:2022-06-23 09:39:04 所属栏目:站长百科 来源:互联网
导读:?php class CreateHtml { function mkdir( $prefix= article ) { $y = date(Y); $m = date(m); $d = date(d); $p=DIRECTORY_SEPARATOR; $filePath=article.$p.$y.$p.$m.$p.$d; $a=explode($p,$filePath); foreach ( $a as $dir) { $path.=$dir.$p; if(!is_di
  <?php
  class CreateHtml
  {
  function mkdir( $prefix= 'article' )
  {
  $y = date('Y');
  $m = date('m');
  $d = date('d');
  $p=DIRECTORY_SEPARATOR;
  $filePath='article'.$p.$y.$p.$m.$p.$d;
  $a=explode($p,$filePath);
  foreach ( $a as $dir)
  {
  $path.=$dir.$p;
  if(!is_dir($path))
  {
  //echo '没有这个目录'.$path;
  mkdir($path,0755);
  }
  }
  return $filePath.$p;
  }
  function start()
  {
  ob_start();
  }
  function end()
  {
  $info = ob_get_contents();
  $fileId = '12345';
  $postfix = '.html';
  $path = $this->mkdir($prefix= 'article');
  $fileName = time().'_'.$fileId.$postfix;
  $file=fopen($path.$fileName,'w ');
  fwrite($file,$info);
  fclose($file);
  ob_end_flush();
  }
  }
  ?>
  <?php
  $s=new CreateHtml();
  $s->start();
  ?>
  <html>
  <body>
  asdfasdfasdfasdfasdfasdfasdfasdfasdf<br>
  adfasdfasdf<br>
  </body>>
  </html>
  <?php
  $s->end();
  ?> 

(编辑:平凉站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读