当前位置: 首页>>代码示例>>PHP>>正文


PHP Console::writef方法代码示例

本文整理汇总了PHP中Console::writef方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::writef方法的具体用法?PHP Console::writef怎么用?PHP Console::writef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Console的用法示例。


在下文中一共展示了Console::writef方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: extract

 /**
  * Extract a ".ar" file into a given target directory
  *
  * @param   string base
  * @param   string ar
  * @param   io.Folder target
  * @throws  lang.IllegalStateException in case the target is not found
  * @throws  lang.FormatException in case the .ar-file is not parseable
  */
 protected function extract($base, $ar, Folder $target)
 {
     // Open a HTTP connection
     $url = new URL($base . $ar . '.ar');
     $r = create(new HttpConnection($url))->get();
     if (HttpConstants::STATUS_OK != $r->getStatusCode()) {
         throw new IllegalStateException(sprintf('Unexpected response %d:%s for %s', $r->getStatusCode(), $r->getMessage(), $url->getURL()));
     }
     $in = new BufferedInputStream($r->getInputStream());
     do {
         // Seach for first section header, --[LENGTH]:[FILENAME]-- and parse it
         do {
             $line = $this->readLine($in);
             if (!$in->available()) {
                 throw new FormatException('Cannot locate section header');
             }
         } while (2 !== sscanf($line, '--%d:%[^:]--', $length, $filename));
         // Calculate target file
         $file = new File($target, $filename);
         $folder = new Folder($file->getPath());
         $folder->exists() || $folder->create();
         Console::writef('     >> [%-10s] %s (%.2f kB) [%s]%s', $ar, $filename, $length / 1024, str_repeat('.', self::PROGRESS_INDICATOR_WIDTH), str_repeat("", self::PROGRESS_INDICATOR_WIDTH + 1));
         // Transfer length bytes into file
         $c = 0;
         $out = $file->getOutputStream();
         $size = 0;
         while ($size < $length) {
             $chunk = $in->read(min(0x1000, $length - $size));
             $size += strlen($chunk);
             $out->write($chunk);
             // Update progress
             $d = ceil($size / $length * self::PROGRESS_INDICATOR_WIDTH);
             if ($d == $c) {
                 continue;
             }
             Console::write(str_repeat('#', $d - $c));
             $c = $d;
         }
         $out->close();
         Console::writeLine();
     } while ($in->available() > 0);
     $in->close();
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:52,代码来源:DownloadAction.class.php

示例2: writef

 public function writef()
 {
     Console::writef('Hello "%s"', 'Timm');
     $this->assertEquals('Hello "Timm"', $this->streams[1]->getBytes());
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:5,代码来源:ConsoleTest.class.php


注:本文中的Console::writef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。