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


PHP JFile::append方法代码示例

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


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

示例1: addEntry

 /**
  * Method to add an entry to the log.
  *
  * @param   JLogEntry  $entry  The log entry object to add to the log.
  *
  * @return  boolean  True on success.
  *
  * @since   11.1
  * @throws  RuntimeException
  */
 public function addEntry(JLogEntry $entry)
 {
     // Initialise the file if not already done.
     $this->initFile();
     // Set some default field values if not already set.
     if (!isset($entry->clientIP)) {
         // Check for proxies as well.
         if (isset($_SERVER['REMOTE_ADDR'])) {
             $entry->clientIP = $_SERVER['REMOTE_ADDR'];
         } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
             $entry->clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
         } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
             $entry->clientIP = $_SERVER['HTTP_CLIENT_IP'];
         }
     }
     // If the time field is missing or the date field isn't only the date we need to rework it.
     if (strlen($entry->date) != 10 || !isset($entry->time)) {
         // Get the date and time strings in GMT.
         $entry->datetime = $entry->date->toISO8601();
         $entry->time = $entry->date->format('H:i:s', false);
         $entry->date = $entry->date->format('Y-m-d', false);
     }
     // Get a list of all the entry keys and make sure they are upper case.
     $tmp = array_change_key_case(get_object_vars($entry), CASE_UPPER);
     // Decode the entry priority into an English string.
     $tmp['PRIORITY'] = $this->priorities[$entry->priority];
     // Fill in field data for the line.
     $line = $this->format;
     foreach ($this->fields as $field) {
         $line = str_replace('{' . $field . '}', isset($tmp[$field]) ? $tmp[$field] : '-', $line);
     }
     // Write the new entry to the file.
     $line .= "\n";
     if (!JFile::append($this->path, $line)) {
         throw new RuntimeException('Cannot write to log file.');
     }
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:47,代码来源:formattedtext.php


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