• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP log函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中log函数的典型用法代码示例。如果您正苦于以下问题:PHP log函数的具体用法?PHP log怎么用?PHP log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: humanReadableBytes

 /**
  * Get human readable file size, quick and dirty.
  * 
  * @todo Improve i18n support.
  *
  * @param int $bytes
  * @param string $format
  * @param int|null $decimal_places
  * @return string Human readable string with file size.
  */
 public static function humanReadableBytes($bytes, $format = "en", $decimal_places = null)
 {
     switch ($format) {
         case "sv":
             $dec_separator = ",";
             $thousands_separator = " ";
             break;
         default:
         case "en":
             $dec_separator = ".";
             $thousands_separator = ",";
             break;
     }
     $b = (int) $bytes;
     $s = array('B', 'kB', 'MB', 'GB', 'TB');
     if ($b <= 0) {
         return "0 " . $s[0];
     }
     $con = 1024;
     $e = (int) log($b, $con);
     $e = min($e, count($s) - 1);
     $v = $b / pow($con, $e);
     if ($decimal_places === null) {
         $decimal_places = max(0, 2 - (int) log($v, 10));
     }
     return number_format($v, !$e ? 0 : $decimal_places, $dec_separator, $thousands_separator) . ' ' . $s[$e];
 }
开发者ID:varvanin,项目名称:currycms,代码行数:37,代码来源:Util.php


示例2: getRoutes

 /**
  * Get Local routes
  * @return array Array of routes
  */
 public function getRoutes()
 {
     // Return a list of routes the machine knows about.
     $route = fpbx_which('route');
     if (empty($route)) {
         return array();
     }
     exec("{$route} -nv", $output, $retcode);
     if ($retcode != 0 || empty($output)) {
         return array();
     }
     // Drop the first two lines, which are just headers..
     array_shift($output);
     array_shift($output);
     // Now loop through whatever's left
     $routes = array();
     foreach ($output as $line) {
         $arr = preg_split('/\\s+/', $line);
         if (count($arr) < 3) {
             //some strange value we dont understand
             continue;
         }
         if ($arr[2] == "0.0.0.0" || $arr[2] == "255.255.255.255") {
             // Don't care about default or host routes
             continue;
         }
         if (substr($arr[0], 0, 7) == "169.254") {
             // Ignore ipv4 link-local addresses. See RFC3927
             continue;
         }
         $cidr = 32 - log((ip2long($arr[2]) ^ 4294967295.0) + 1, 2);
         $routes[] = array($arr[0], $cidr);
     }
     return $routes;
 }
开发者ID:ntadmin,项目名称:firewall,代码行数:39,代码来源:Natget.class.php


示例3: filesize_formatted

function filesize_formatted($path)
{
    $size = filesize($path);
    $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
    $power = $size > 0 ? floor(log($size, 1024)) : 0;
    return number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power];
}
开发者ID:NXij,项目名称:Cherry,代码行数:7,代码来源:index.php


示例4: fileSize

 /**
  * Format a filesize
  *
  * @param int $size In bytes
  * @return string
  */
 public function fileSize($size)
 {
     if (!$size) {
         return '0 ' . $this->_sizes[0];
     }
     return round($size / pow(1024, $i = floor(log($size, 1024))), $i > 1 ? 2 : 0) . ' ' . $this->_sizes[$i];
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:13,代码来源:FileSize.php


示例5: classify

 public function classify($string)
 {
     if ($this->total_samples === 0) {
         return array();
     }
     $tokens = $this->tokenizer->tokenize($string);
     $total_score = 0;
     $scores = array();
     foreach ($this->subjects as $subject => $subject_data) {
         $subject_data['prior_value'] = log($subject_data['count_samples'] / $this->total_samples);
         $this->subjects[$subject] = $subject_data;
         $scores[$subject] = 0;
         foreach ($tokens as $token) {
             $count = isset($this->tokens[$token][$subject]) ? $this->tokens[$token][$subject] : 0;
             $scores[$subject] += log(($count + 1) / ($subject_data['count_tokens'] + $this->total_tokens));
         }
         $scores[$subject] = $subject_data['prior_value'] + $scores[$subject];
         $total_score += $scores[$subject];
     }
     $min = min($scores);
     $sum = 0;
     foreach ($scores as $subject => $score) {
         $scores[$subject] = exp($score - $min);
         $sum += $scores[$subject];
     }
     $total = 1 / $sum;
     foreach ($scores as $subject => $score) {
         $scores[$subject] = $score * $total;
     }
     arsort($scores);
     $max = max($scores);
     $maxs = array_search(max($scores), $scores);
     return $maxs;
 }
开发者ID:nhunght,项目名称:mork_SmartOSC,代码行数:34,代码来源:Classifier.php


示例6: calculate

 /**
  * @throws RegressionException
  */
 public function calculate()
 {
     if ($this->sourceSequence === null) {
         throw new RegressionException('The input sequence is not set');
     }
     if (count($this->sourceSequence) < $this->dimension) {
         throw new RegressionException(sprintf('The dimension of the sequence of at least %s', $this->dimension));
     }
     $k = 0;
     foreach ($this->sourceSequence as $k => $v) {
         if ($v[1] !== null) {
             $this->sumIndex[0] += log($v[0]);
             $this->sumIndex[1] += log($v[0]) * log($v[1]);
             $this->sumIndex[2] += log($v[1]);
             $this->sumIndex[3] += pow(log($v[0]), 2);
         }
     }
     $k += 1;
     $B = ($k * $this->sumIndex[1] - $this->sumIndex[2] * $this->sumIndex[0]) / ($k * $this->sumIndex[3] - $this->sumIndex[0] * $this->sumIndex[0]);
     $A = exp(($this->sumIndex[2] - $B * $this->sumIndex[0]) / $k);
     foreach ($this->sourceSequence as $i => $val) {
         $coordinate = [$val[0], $A * pow($val[0], $B)];
         $this->resultSequence[] = $coordinate;
     }
     $this->equation = sprintf('y = %s + x^%s', round($A, 2), round($B, 2));
     $this->push();
 }
开发者ID:robotomize,项目名称:regression-php,代码行数:30,代码来源:PowerRegression.php


示例7: getLiteralSizeFormat

 /**
  * Return the literal size of $bytes with the appropriate suffix (bytes, KB, MB, GB)
  *
  * @param integer $bytes
  * @return string
  */
 public static function getLiteralSizeFormat($bytes)
 {
     if (!$bytes) {
         return false;
     }
     $exp = floor(log($bytes, 1024));
     switch ($exp) {
         case 0:
             // bytes
             $suffix = ' bytes';
             break;
         case 1:
             // KB
             $suffix = ' KB';
             break;
         case 2:
             // MB
             $suffix = ' MB';
             break;
         case 3:
             // GB
             $suffix = ' GB';
             break;
     }
     return round($bytes / pow(1024, $exp), 1) . $suffix;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:32,代码来源:System.class.php


示例8: numbersFormatting

function numbersFormatting($bytes)
{
    $si_prefix = array('B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB');
    $base = 1024;
    $class = min((int) log($bytes, $base), count($si_prefix) - 1);
    return sprintf('%1.2f', $bytes / pow($base, $class)) . ' ' . $si_prefix[$class];
}
开发者ID:jamiebatch452,项目名称:Open-Game-Panel,代码行数:7,代码来源:get_size.php


示例9: bytes

	/**
	 * Converts bytes to more distinguishable formats such as:
	 * kilobytes, megabytes, etc.
	 *
	 * By default, the proper format will automatically be chosen.
	 * However, one of the allowed unit types may also be used instead.
	 *
	 * @param   integer  $bytes      The number of bytes.
	 * @param   string   $unit       The type of unit to return.
	 * @param   integer  $precision  The number of digits to be used after the decimal place.
	 *
	 * @return  string   The number of bytes in the proper units.
	 *
	 * @since   11.1
	 */
	public static function bytes($bytes, $unit = 'auto', $precision = 2)
	{
		$bytes = (int) $bytes;
		$precision = (int) $precision;

		if (empty($bytes))
		{
			return 0;
		}

		$unitTypes = array('b', 'kb', 'MB', 'GB', 'TB', 'PB');

		// Default automatic method.
		$i = floor(log($bytes, 1024));

		// User supplied method:
		if ($unit !== 'auto' && in_array($unit, $unitTypes))
		{
			$i = array_search($unit, $unitTypes, true);
		}

		// TODO Allow conversion of units where $bytes = '32M'.

		return round($bytes / pow(1024, $i), $precision) . ' ' . $unitTypes[$i];
	}
开发者ID:nikosdion,项目名称:Akeeba-Example,代码行数:40,代码来源:number.php


示例10: formatBytes

 function formatBytes($size, $precision = 2)
 {
     //TODO: Scegliere se visualizzare in base binaria o decimale.
     $base = log($size) / log(1024);
     $suffixes = array(' B', ' KiB', ' MiB', ' GiB', ' TiB');
     return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
 }
开发者ID:borisper1,项目名称:vesi-cms,代码行数:7,代码来源:file-lister.php


示例11: saveMenuCache

 public function saveMenuCache()
 {
     try {
         //$defaultStoreId = Mage::app()->getWebsite()->getDefaultGroup()->getDefaultStoreId();
         //Mage::app()->setCurrentStore($defaultStoreId);
         //Mage::getSingleton('core/session', array('name'=>'frontend'));
         //$_layout  = Mage::getSingleton('core/layout');
         //$_block  =	$_layout->createBlock('page/html_topmenu')/*->setTemplate('page/html/topmenu.phtml')*/;
         //$html=$_block->getHtml();
         Mage::app()->loadArea('frontend');
         $layout = Mage::getSingleton('core/layout');
         //load default xml layout handle and generate blocks
         $layout->getUpdate()->load('default');
         $layout->generateXml()->generateBlocks();
         //get the loaded head and header blocks and output
         $headerBlock = $layout->getBlock('header');
         $html = $headerBlock->toHtml();
         $filename = dirname(Mage::getRoot()) . DS . 'media' . DS . 'wp' . DS . 'topmenu';
         file_put_contents($filename, $html);
         //Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
         //Mage::getSingleton('core/session', array('name'=>'admintml'));
     } catch (Exception $e) {
         Mage:
         log($e->getMessage(), null, 'wp_menu_error.log');
     }
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:26,代码来源:Wpmenu000.php


示例12: populateParagraphTFs

function populateParagraphTFs()
{
    $query = "SELECT * from paragraph;";
    $result = mysql_query($query);
    $N = mysql_num_rows($result);
    while ($row = mysql_fetch_array($result)) {
        echo $row['id'];
        $query = "SELECT paragraph_id, COUNT(word_id) as count, word_id FROM sentence, sentence_xref_word WHERE sentence.id = sentence_id AND paragraph_id = " . $row['id'] . " GROUP BY word_id;";
        $counts = mysql_query($query);
        while ($count = mysql_fetch_array($counts)) {
            $query = "SELECT paragraph_frequency, word from word_idf WHERE word_id = " . $count['word_id'] . ";";
            $df = mysql_query($query);
            $df = mysql_fetch_array($df);
            $word = mysql_real_escape_string($df['word']);
            $df = $df['paragraph_frequency'];
            if ($df) {
                $idf = log($N / $df);
                $tf_idf = $count['count'] * $idf;
                $query = "INSERT INTO paragraph_tf (paragraph_id, word_id, tf, tf_idf, word) VALUES (" . $row['id'] . ", " . $count['word_id'] . ", " . $count['count'] . ", " . $tf_idf . ",'" . $word . "');";
                mysql_query($query) or die("<b>A fatal MySQL error occured</b>.\n\t\t\t\t\t<br/> Query: " . $query . "\n\t\t\t\t\t<br/> Error: (" . mysql_errno() . ") " . mysql_error());
            }
        }
        echo "\n";
    }
}
开发者ID:xiaobaozi34,项目名称:WordSeer-1,代码行数:25,代码来源:populate-tf-idf.php


示例13: approximate

 public function approximate()
 {
     $correlation = $this->getCorrelation();
     $step = $this->getStep();
     $this->_tau = 0;
     for ($i = 0; $i < count($correlation); $i++) {
         if ($correlation[$i] < 0) {
             $p1 = new Model_Coordinate($step * ($i - 1), $correlation[$i - 1]);
             $p2 = new Model_Coordinate($step * $i, $correlation[$i]);
             $k = ($p2->getY() - $p1->getY()) / ($p2->getX() - $p1->getX());
             $b = $p2->getY() - $k * $p2->getX();
             $this->_tau = -$b / $k;
             break;
         }
     }
     $this->_beta = pi() / (2 * $this->_tau);
     $s1 = 0;
     $s2 = 0;
     for ($i = 0; $i * $step < $this->_tau; $i++) {
         $tau = $i * $step;
         $ro_tau = $correlation[$i];
         $s1 += abs($tau * log($ro_tau / cos($this->_beta * $tau)));
         $s2 += $tau * $tau;
     }
     if ($this->_tau < $step) {
         $this->_alpha = 1;
     } else {
         $this->_alpha = $s1 / $s2;
     }
 }
开发者ID:nikita-prikazchikov,项目名称:RoadEstimation,代码行数:30,代码来源:Microprofile.php


示例14: _DEBUG

function _DEBUG($b_valAll = 0, $s_msgtype = 'both|con|ech|printr|vardump', $s_msg = '', $s_default = '')
{
    if ($b_valAll === 1 && $s_msgtype != '') {
        if ($s_msgtype === 'both') {
            echo '<br />===DEBUG===<br />' . $s_msg . '<br />===DEBUG===<br />';
            console . log($s_msg) . '<br />';
        } else {
            if ($s_msgtype === 'ech') {
                echo '<br />===DEBUG===<br />' . $s_msg . '<br />===DEBUG===<br />';
            } else {
                if ($s_msgtype === 'con') {
                    '<br />===DEBUG===<br />' . console . log($s_msg) . '<br />===DEBUG===<br />';
                } else {
                    if ($s_msgtype === 'printr') {
                        '<br />===DEBUG===<br />' . print_r($s_msg) . '<br />===DEBUG===<br />';
                    } else {
                        if ($s_msgtype === 'vardump') {
                            '<br />===DEBUG===<br />' . var_dump($s_msg) . '<br />===DEBUG===<br />';
                        }
                    }
                }
            }
        }
    } else {
        if ($b_valAll === 0 && $s_msgtype != '') {
            echo $s_default;
        }
    }
}
开发者ID:SebThieu,项目名称:calendar,代码行数:29,代码来源:fonction.php


示例15: getRounds

 public static function getRounds($tour_id)
 {
     global $conn;
     $sql = "SELECT team_count,tournament_type as tour_type from event_tournament WHERE id=:tour_id";
     $sth = $conn->prepare($sql);
     $sth->bindValue('tour_id', $tour_id);
     try {
         $sth->execute();
     } catch (Exception $e) {
     }
     $result = $sth->fetchAll(PDO::FETCH_ASSOC);
     $team_count = $result[0]['team_count'];
     $tour_type = $result[0]['tour_type'];
     /*if($team_count>2 && $team_count<=4)
     		$rounds=2;
     	elseif($team_count>4 && $team_count<=8)
     		$rounds=3;
     	elseif ($team_count>8 && $team_count<=16)
     		$rounds=4;
     	elseif ($team_count>16 && $team_count<=32)
     		$rounds=5;
     	else
     		$rounds=6;*/
     if ($tour_type == 1) {
         $rounds = ceil(log($team_count, 2));
     } else {
         $rounds = ceil(log($team_count, 2)) + ceil(log(log($team_count, 2), 2));
     }
     return $rounds;
 }
开发者ID:Gameonn,项目名称:basketball,代码行数:30,代码来源:Scheduling.php


示例16: _parse

 protected function _parse(&$variable)
 {
     if (!is_string($variable) || !preg_match('[0\\.[0-9]{8} [0-9]{10}]', $variable)) {
         return false;
     }
     list($usec, $sec) = explode(" ", $variable);
     $time = (double) $usec + (double) $sec;
     if (KINT_PHP53) {
         $size = memory_get_usage(true);
     }
     # '@' is used to prevent the dreaded timezone not set error
     $this->value = @date('Y-m-d H:i:s', $sec) . '.' . substr($usec, 2, 4);
     $numberOfCalls = count(self::$_times);
     if ($numberOfCalls > 0) {
         # meh, faster than count($times) > 1
         $lap = $time - end(self::$_times);
         self::$_laps[] = $lap;
         $this->value .= "\n<b>SINCE LAST CALL:</b> <b class=\"kint-microtime\">" . round($lap, 4) . '</b>s.';
         if ($numberOfCalls > 1) {
             $this->value .= "\n<b>SINCE START:</b> " . round($time - self::$_times[0], 4) . 's.';
             $this->value .= "\n<b>AVERAGE DURATION:</b> " . round(array_sum(self::$_laps) / $numberOfCalls, 4) . 's.';
         }
     }
     $unit = array('B', 'KB', 'MB', 'GB', 'TB');
     if (KINT_PHP53) {
         $this->value .= "\n<b>MEMORY USAGE:</b> " . $size . " bytes (" . round($size / pow(1024, $i = floor(log($size, 1024))), 3) . ' ' . $unit[$i] . ")";
     }
     self::$_times[] = $time;
     $this->type = 'Stats';
 }
开发者ID:karlpatrickespiritu,项目名称:kint,代码行数:30,代码来源:microtime.php


示例17: getScore

 /**
  * Prosty "algorytm" do generowania rankingu danego wpisu na podstawie ocen i czasu dodania
  *
  * @param $votes
  * @param $bonus
  * @param $timestamp
  * @return int
  */
 public static function getScore($votes, $bonus, $timestamp)
 {
     $log = $votes || $bonus ? log($votes + $bonus, 2) : 0;
     // magia dzieje sie tutaj :) ustalanie "mocy" danego wpisu. na tej podstawie wyswietlane
     // sa wpisy na stronie glownej. liczba glosow swiadczy o ich popularnosci
     return (int) ($log + $timestamp / 45000);
 }
开发者ID:furious-programming,项目名称:coyote,代码行数:15,代码来源:Microblog.php


示例18: MakeCloud

 /**
  * Строит логарифмическое облако - расчитывает значение size в зависимости от count
  * У объектов в коллекции обязательно должны быть методы getCount() и setSize()
  *
  * @param array $aCollection   Список тегов
  * @param int  $iMinSize       Минимальный размер
  * @param int  $iMaxSize       Максимальный размер
  *
  * @return array
  */
 public function MakeCloud($aCollection, $iMinSize = 1, $iMaxSize = 10)
 {
     if (count($aCollection)) {
         $iSizeRange = $iMaxSize - $iMinSize;
         $iMin = 10000;
         $iMax = 0;
         foreach ($aCollection as $oObject) {
             if ($iMax < $oObject->getCount()) {
                 $iMax = $oObject->getCount();
             }
             if ($iMin > $oObject->getCount()) {
                 $iMin = $oObject->getCount();
             }
         }
         $iMinCount = log($iMin + 1);
         $iMaxCount = log($iMax + 1);
         $iCountRange = $iMaxCount - $iMinCount;
         if ($iCountRange == 0) {
             $iCountRange = 1;
         }
         foreach ($aCollection as $oObject) {
             $iTagSize = $iMinSize + (log($oObject->getCount() + 1) - $iMinCount) * ($iSizeRange / $iCountRange);
             $oObject->setSize(round($iTagSize));
         }
     }
     return $aCollection;
 }
开发者ID:AntiqS,项目名称:altocms,代码行数:37,代码来源:Tools.class.php


示例19: getInteger

 public static function getInteger($min = 0, $max = 0x7fffffff)
 {
     $bytes_required = min(4, ceil(log($max - $min, 2) / 8) + 1);
     $bytes = self::getBinary($bytes_required);
     $offset = abs(hexdec(bin2hex($bytes)) % ($max - $min + 1));
     return intval($min + $offset);
 }
开发者ID:kyhfan,项目名称:babience_awards,代码行数:7,代码来源:phprandom.php


示例20: smarty_modifier_filesize

/**
 * Smarty replace modifier plugin
 * 
 * Type:     modifier<br>
 * Name:     filesize<br>
 * Purpose:  show the filesize of a file in kb, mb, gb etc...
 * 
 * @param string $ 
 * @return string 
*/
function smarty_modifier_filesize($size)
{
    $size = max(0, (int) $size);
    $units = array('بایت', 'کیلوبایت', 'مگابایت', 'گیگابایت', 'ترابایت', 'پتابایت', 'اتابایت', 'زتابایت', 'یتابایت');
    $power = $size > 0 ? floor(log($size, 1024)) : 0;
    return number_format($size / pow(1024, $power), 2, '.', ',') . $units[$power];
}
开发者ID:rezarahimi4861,项目名称:icmf,代码行数:17,代码来源:modifier.filesize.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP log10函数代码示例发布时间:2022-05-15
下一篇:
PHP lock函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap