當前位置: 首頁>>代碼示例>>PHP>>正文


PHP File::putContents方法代碼示例

本文整理匯總了PHP中Bitrix\Main\IO\File::putContents方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::putContents方法的具體用法?PHP File::putContents怎麽用?PHP File::putContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Bitrix\Main\IO\File的用法示例。


在下文中一共展示了File::putContents方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: writeStatistic

 /**
  * Updates cache usage statistics.
  * Each of parameters is added to appropriate existing stats.
  *
  * @param int $hit
  * @param int $miss
  * @param int $quota
  * @param int $posts
  * @param float $files
  * @return void
  */
 public function writeStatistic($hit = 0, $miss = 0, $quota = 0, $posts = 0, $files = 0.0)
 {
     $fileValues = $this->readStatistic();
     if ($fileValues) {
         $newValues = array(intval($fileValues["HITS"]) + $hit, intval($fileValues["MISSES"]) + $miss, intval($fileValues["QUOTA"]) + $quota, intval($fileValues["POSTS"]) + $posts, $files === false ? 0 : doubleval($fileValues["FILE_SIZE"]) + doubleval($files));
         $this->statFile->putContents(implode(",", $newValues));
     }
 }
開發者ID:spas-viktor,項目名稱:books,代碼行數:19,代碼來源:statichtmlcache.php

示例2: appendContentNonCloud

 private function appendContentNonCloud($fileContent, $startRange, $endRange, $fileSize)
 {
     $file = new IO\File($this->getAbsolutePath());
     if (!$file->isExists()) {
         $this->errorCollection->addOne(new Error('Could not find file', static::ERROR_EXISTS_FILE));
         return false;
     }
     if ($file->putContents($fileContent, $file::APPEND) === false) {
         $this->errorCollection->addOne(new Error('Could not put contents to file', static::ERROR_PUT_CONTENTS));
         return false;
     }
     return true;
 }
開發者ID:DarneoStudio,項目名稱:bitrix,代碼行數:13,代碼來源:tmpfile.php

示例3: write

 public function write($arAllVars, $baseDir, $initDir, $filename, $TTL)
 {
     $documentRoot = \Bitrix\Main\Application::getDocumentRoot();
     $fn = IO\Path::combine($documentRoot, $baseDir, $initDir, $filename);
     $file = new IO\File($fn);
     $fnTmp = IO\Path::combine($documentRoot, $baseDir, $initDir, md5(mt_rand()) . ".tmp");
     $fileTmp = new IO\File($fnTmp);
     $dir = $file->getDirectory();
     if (!$dir->isExists()) {
         $dir->create();
     }
     if (is_array($arAllVars)) {
         $contents = "<?";
         $contents .= "\nif(\$INCLUDE_FROM_CACHE!='Y')return false;";
         $contents .= "\n\$datecreate = '" . str_pad(mktime(), 12, "0", STR_PAD_LEFT) . "';";
         $contents .= "\n\$dateexpire = '" . str_pad(mktime() + IntVal($TTL), 12, "0", STR_PAD_LEFT) . "';";
         $v = serialize($arAllVars);
         if (static::checkZeroDanger()) {
             $v = str_replace("*", "", $v);
             $contents .= "\n\$zeroDanger = true;";
         }
         $contents .= "\n\$ser_content = '" . str_replace("'", "\\'", str_replace("\\", "\\\\", $v)) . "';";
         $contents .= "\nreturn true;";
         $contents .= "\n?>";
     } else {
         $contents = "BX" . str_pad(mktime(), 12, "0", STR_PAD_LEFT) . str_pad(mktime() + IntVal($this->TTL), 12, "0", STR_PAD_LEFT);
         $contents .= $arAllVars;
     }
     $this->written = $fileTmp->putContents($contents);
     $len = \Bitrix\Main\Text\String::strlenBytes($contents);
     //This checks for Zend Server CE in order to supress warnings
     if (function_exists('accelerator_reset')) {
         try {
             $file->delete();
         } catch (\Exception $ex) {
         }
     } elseif ($file->isExists()) {
         $file->delete();
     }
     if ($this->written === $len) {
         $fileTmp->rename($fn);
     }
     //This checks for Zend Server CE in order to supress warnings
     if (function_exists('accelerator_reset')) {
         try {
             IO\File::deleteFile($fnTmp);
         } catch (\Exception $ex) {
         }
     } elseif (IO\File::isFileExists($fnTmp)) {
         IO\File::deleteFile($fnTmp);
     }
 }
開發者ID:,項目名稱:,代碼行數:52,代碼來源:

示例4: _saveData

 /**
  * @param array $value
  * @return $this
  */
 private function _saveData(array $value = null)
 {
     $this->_file->putContents(\WS\Migrations\arrayToJson($value));
     return $this;
 }
開發者ID:ASDAFF,項目名稱:bitrix-module-migrations,代碼行數:9,代碼來源:collector.php

示例5: writeDebug

 /**
  * Writes a debug information in a log file
  */
 private function writeDebug()
 {
     if (!$this->debugEnabled || !defined("BX_COMPOSITE_DEBUG") || BX_COMPOSITE_DEBUG !== true || !$this->storage->exists()) {
         return;
     }
     if (!$this->storage->shouldCountQuota() || \CHTMLPagesCache::checkQuota()) {
         //temporary check
         if ($this->storage instanceof StaticHtmlFileStorage) {
             $cacheFile = $this->storage->getCacheFile();
             $backupName = $cacheFile->getPath() . ".delete." . microtime(true);
             AddMessage2Log($backupName, "composite");
             $backupFile = new Main\IO\File($backupName);
             $backupFile->putContents($cacheFile->getContents());
             \CHTMLPagesCache::writeStatistic(0, 0, 0, 0, $cacheFile->getSize());
         } else {
             AddMessage2Log($this->cacheKey . " was deleted", "composite");
         }
     } else {
         AddMessage2Log($this->cacheKey . "(quota exceeded)", "composite");
     }
 }
開發者ID:DarneoStudio,項目名稱:bitrix,代碼行數:24,代碼來源:statichtmlcache.php


注:本文中的Bitrix\Main\IO\File::putContents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。