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


PHP log函数代码示例

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


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


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