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


PHP CFile::read方法代码示例

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


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

示例1: rawPost

 /**
  * Returns the data that was sent with the request if the request's HTTP method is POST.
  *
  * @return CUStringObject The raw POST data.
  */
 public static function rawPost()
 {
     return CFile::read("php://input");
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:9,代码来源:CRequest.php

示例2: testSetPosToStart

 public function testSetPosToStart()
 {
     $filePath = CFile::createTemporary();
     CFile::write($filePath, "Hello there!");
     $file = new CFile($filePath, CFile::READ);
     $data = $file->readBytes(5);
     $this->assertTrue($data->equals("Hello"));
     $file->setPosToStart();
     $data = $file->readBytes(2);
     $this->assertTrue($data->equals("He"));
     $file->done();
     // only needed in these tests
     $file = new CFile($filePath, CFile::WRITE_NEW);
     $file->writeBytes("Hello");
     $file->setPosToStart();
     $file->writeBytes("th");
     $file->done();
     // only needed in these tests
     $this->assertTrue(CFile::read($filePath)->equals("thllo"));
     CFile::delete($filePath);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:21,代码来源:CFileTest.php

示例3: 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

示例4: readAndAddConfig

 protected static function readAndAddConfig($configFp, $configName, $configs)
 {
     if (CMap::hasKey(self::$ms_configAliases, $configName)) {
         $configName = self::$ms_configAliases[$configName];
     }
     $configName = CString::toLowerCase($configName);
     $configJson = CFile::read($configFp);
     $configJson = CRegex::remove($configJson, "/^\\h*\\/\\/.*/m");
     // remove comments
     $configJson = "{\"{$configName}\": {$configJson}}";
     $json = new CJson($configJson);
     $success;
     $config = $json->decode($success);
     assert('$success', vs(isset($this), get_defined_vars()));
     CArray::push($configs, $config);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:16,代码来源:CConfiguration.php


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