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


PHP CFile::write方法代码示例

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


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

示例1: testClone

 public function testClone()
 {
     $filePath0 = CFile::createTemporary();
     $filePath1 = CFile::createTemporary();
     $filePath2 = CFile::createTemporary();
     $filePath3 = CFile::createTemporary();
     CFile::write($filePath0, "The quick");
     CFile::write($filePath1, " brown fox");
     CFile::write($filePath2, " jumps over");
     CFile::write($filePath3, " the lazy dog.");
     $hash0 = new CHash(CHash::SHA256);
     $hash0->computeMoreFromFile($filePath0);
     $hash0->computeMoreFromFile($filePath1);
     $hash0->computeMoreFromFile($filePath2);
     $hash0->computeMoreFromFile($filePath3);
     $hash1 = clone $hash0;
     $hash1->computeMoreFromFile($filePath0);
     $this->assertTrue($hash0->finalize()->equals("ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c"));
     $this->assertTrue($hash1->finalize()->equals("14dc40e99be202c4e59a0c6d1a8854bb50253624080435ed8c65bd6e5e880c95"));
     CFile::delete($filePath0);
     CFile::delete($filePath1);
     CFile::delete($filePath2);
     CFile::delete($filePath3);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:24,代码来源:CHashTest.php

示例2: onThirdPartyUpdateByPackageManager

 /**
  * @ignore
  */
 public static function onThirdPartyUpdateByPackageManager()
 {
     if (!self::isInCliMode()) {
         // This method can be run in CLI mode only.
         assert('false', vs(isset($this), get_defined_vars()));
     }
     $timeoutPause = new CTimeoutPause();
     CShell::speak("Processing third-party components ...");
     $tpDps = CFile::listDirectories(CFilePath::absolute($GLOBALS["PHRED_PATH_TO_THIRD_PARTY"]));
     $ignorePackages = CConfiguration::option("upd.thirdPartyOopWrappingIgnorePackages");
     $ignorePackagesL2 = CArray::filter($ignorePackages, function ($package) {
         return CString::find($package, "/");
     });
     $newTpDps = CArray::make();
     $len = CArray::length($tpDps);
     for ($i = 0; $i < $len; $i++) {
         $tpDp = $tpDps[$i];
         $dirName = CFilePath::name($tpDp);
         if (!CArray::find($ignorePackages, $dirName)) {
             $dpHasL2DirsToIgnore = CArray::find($ignorePackagesL2, $dirName, function ($packageL2, $dirName) {
                 return CString::equals(CFilePath::directory($packageL2), $dirName);
             });
             if (!$dpHasL2DirsToIgnore) {
                 CArray::push($newTpDps, $tpDp);
             } else {
                 $tpSubDps = CFile::listDirectories($tpDp);
                 $tpSubDps = CArray::filter($tpSubDps, function ($subDp) use($ignorePackagesL2) {
                     return !CArray::find($ignorePackagesL2, $subDp, function ($packageL2, $subDp) {
                         return CString::endsWith($subDp, $packageL2);
                     });
                 });
                 CArray::pushArray($newTpDps, $tpSubDps);
             }
         }
     }
     $tpDps = $newTpDps;
     $wrapProtectedMethods = CConfiguration::option("upd.thirdPartyOopWrappingInProtectedMethods");
     $wrapPrivateMethods = CConfiguration::option("upd.thirdPartyOopWrappingInPrivateMethods");
     static $s_stdPhpTag = "<?php";
     static $s_progressResolution = 0.05;
     $prevProgressDivR = 0;
     $tpDpsLen = CArray::length($tpDps);
     for ($i0 = 0; $i0 < $tpDpsLen; $i0++) {
         $tpFps = CFile::reFindFilesRecursive($tpDps[$i0], "/\\.php\\d?\\z/");
         $tpFpsLen = CArray::length($tpFps);
         for ($i1 = 0; $i1 < $tpFpsLen; $i1++) {
             $fileCode = CFile::read($tpFps[$i1]);
             if (!CString::find($fileCode, self::$ms_thirdPartyAlreadyOopWrappedMark)) {
                 $parser = new PhpParser\Parser(new PhpParser\Lexer());
                 try {
                     // Parse the code.
                     $statements = $parser->parse($fileCode);
                     // Wrap the code into OOP.
                     $traverser = new PhpParser\NodeTraverser();
                     $mainVisitor = new CMainVisitor($wrapProtectedMethods, $wrapPrivateMethods);
                     $traverser->addVisitor($mainVisitor);
                     $statements = $traverser->traverse($statements);
                     $wrappedCode = (new PhpParser\PrettyPrinter\Standard())->prettyPrint($statements);
                     $phpTagPos = CString::indexOf($wrappedCode, $s_stdPhpTag);
                     if ($phpTagPos == -1) {
                         $wrappedCode = "{$s_stdPhpTag}\n\n{$wrappedCode}";
                         $phpTagPos = 0;
                     }
                     $wrappedCode = CString::insert($wrappedCode, $phpTagPos + CString::length($s_stdPhpTag), "\n\n" . self::$ms_thirdPartyAlreadyOopWrappedMark);
                     // Save.
                     CFile::write($tpFps[$i1], $wrappedCode);
                 } catch (PhpParser\Error $parserError) {
                     CShell::say("\nPhpParser: " . $tpFps[$i1] . ", at line " . $parserError->getRawLine() . ": " . $parserError->getRawMessage());
                 }
             }
             $progress = (double) ($i0 / $tpDpsLen + 1 / $tpDpsLen * $i1 / $tpFpsLen);
             $progressDivR = CMathi::floor($progress / $s_progressResolution);
             if ($progressDivR != $prevProgressDivR) {
                 $perc = CMathi::round($progressDivR * $s_progressResolution * 100);
                 CShell::speak("{$perc}%");
             }
             $prevProgressDivR = $progressDivR;
         }
     }
     CShell::speak("100%");
     CShell::say("Done.");
     $timeoutPause->end();
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:86,代码来源:CSystem.php

示例3: testIsPosPastEnd

 public function testIsPosPastEnd()
 {
     $filePath = CFile::createTemporary();
     CFile::write($filePath, "Hello");
     $file = new CFile($filePath, CFile::READ);
     $file->readBytes(5);
     $this->assertFalse($file->isPosPastEnd());
     $file->done();
     // only needed in these tests
     CFile::write($filePath, "Hello");
     $file = new CFile($filePath, CFile::READ);
     $file->setPosToEnd();
     $this->assertFalse($file->isPosPastEnd());
     $file->done();
     // only needed in these tests
     CFile::write($filePath, "Hello");
     $file = new CFile($filePath, CFile::READ);
     $file->readBytes(5);
     $data = $file->readAvailableBytes(5);
     $this->assertTrue($file->isPosPastEnd() && $data->equals(""));
     $file->done();
     // only needed in these tests
     CFile::delete($filePath);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:24,代码来源:CFileTest.php

示例4: writeCSVRecords

 private static function writeCSVRecords($file, $request_id, $records)
 {
     $f = new CFile($file);
     $f->open('a');
     foreach ($records as $fields) {
         $f->write($request_id . self::csv_fields_delimiter);
         $f->write(implode(self::csv_fields_delimiter, $fields));
         $f->write(self::csv_lines_delimiter);
     }
     $f->close();
 }
开发者ID:KICHIRO20,项目名称:-Myproject_part1-,代码行数:11,代码来源:profiler.php

示例5: setUploadData

 /**
  * For any request that needs to upload a file, specifies the data to be uploaded and, for HTTP requests, the
  * file's metadata.
  *
  * For large data, `setUploadFile` method would be preferred to upload an already existing file.
  *
  * @param  data $data The data to be uploaded.
  * @param  string $mimeType **OPTIONAL.** *Required for `HTTP_UPLOAD` requests only.* The MIME type of the file.
  * @param  string $fileName **OPTIONAL.** *Required for `HTTP_UPLOAD` requests only.* The custom name of the file.
  * @param  string $fileId **OPTIONAL.** *Required for `HTTP_UPLOAD` requests only.* The ID under which the file is
  * to arrive to the destination server.
  *
  * @return void
  *
  * @link   #method_setUploadFile setUploadFile
  */
 public function setUploadData($data, $mimeType = null, $fileName = null, $fileId = null)
 {
     assert('is_cstring($data) && (!isset($mimeType) || is_cstring($mimeType)) && ' . '(!isset($fileName) || is_cstring($fileName)) && (!isset($fileId) || is_cstring($fileId))', vs(isset($this), get_defined_vars()));
     $this->m_fileUploadTempFp = CFile::createTemporary();
     CFile::write($this->m_fileUploadTempFp, $data);
     $this->setUploadFile($this->m_fileUploadTempFp, $mimeType, $fileName, $fileId);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:23,代码来源:CInetRequest.php


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