本文整理汇总了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");
}
示例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);
}
示例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();
}
示例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);
}