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


PHP PMA_pow函数代码示例

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


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

示例1: _testNegativeExpGmppow

 public function _testNegativeExpGmppow()
 {
     if (function_exists('gmp_pow')) {
         $this->assertEquals(0.25, PMA_pow(2, -2, 'gmp_pow'));
     } else {
         $this->markTestSkipped('function gmp_pow() does not exist');
     }
 }
开发者ID:bharathi26,项目名称:openemr,代码行数:8,代码来源:PMA_pow_test.php

示例2: PMA_ipMaskTest

/**
 * Based on IP Pattern Matcher
 * Originally by J.Adams <jna@retina.net>
 * Found on <http://www.php.net/manual/en/function.ip2long.php>
 * Modified for phpMyAdmin
 *
 * Matches:
 * xxx.xxx.xxx.xxx        (exact)
 * xxx.xxx.xxx.[yyy-zzz]  (range)
 * xxx.xxx.xxx.xxx/nn     (CIDR)
 *
 * Does not match:
 * xxx.xxx.xxx.xx[yyy-zzz]  (range, partial octets not supported)
 *
 * @param string $testRange string of IP range to match
 * @param string $ipToTest  string of IP to test against range
 *
 * @return boolean    always true
 *
 * @access  public
 */
function PMA_ipMaskTest($testRange, $ipToTest)
{
    $result = true;
    $match = preg_match('|([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)/([0-9]+)|', $testRange, $regs);
    if ($match) {
        // performs a mask match
        $ipl = ip2long($ipToTest);
        $rangel = ip2long($regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' . $regs[4]);
        $maskl = 0;
        for ($i = 0; $i < 31; $i++) {
            if ($i < $regs[5] - 1) {
                $maskl = $maskl + PMA_pow(2, 30 - $i);
            }
            // end if
        }
        // end for
        if (($maskl & $rangel) == ($maskl & $ipl)) {
            return true;
        } else {
            return false;
        }
    } else {
        // range based
        $maskocts = explode('.', $testRange);
        $ipocts = explode('.', $ipToTest);
        // perform a range match
        for ($i = 0; $i < 4; $i++) {
            if (preg_match('|\\[([0-9]+)\\-([0-9]+)\\]|', $maskocts[$i], $regs)) {
                if ($ipocts[$i] > $regs[2] || $ipocts[$i] < $regs[1]) {
                    $result = false;
                }
                // end if
            } else {
                if ($maskocts[$i] != $ipocts[$i]) {
                    $result = false;
                }
                // end if
            }
            // end if/else
        }
        //end for
    }
    //end if/else
    return $result;
}
开发者ID:nicokaiser,项目名称:phpmyadmin,代码行数:66,代码来源:ip_allow_deny.lib.php

示例3: PMA_extractValueFromFormattedSize

/**
 * Returns the number of bytes when a formatted size is given
 *
 * @param string $formatted_size the size expression (for example 8MB)
 *
 * @return  integer  The numerical part of the expression (for example 8)
 */
function PMA_extractValueFromFormattedSize($formatted_size)
{
    $return_value = -1;
    if (preg_match('/^[0-9]+GB$/', $formatted_size)) {
        $return_value = substr($formatted_size, 0, -2) * PMA_pow(1024, 3);
    } elseif (preg_match('/^[0-9]+MB$/', $formatted_size)) {
        $return_value = substr($formatted_size, 0, -2) * PMA_pow(1024, 2);
    } elseif (preg_match('/^[0-9]+K$/', $formatted_size)) {
        $return_value = substr($formatted_size, 0, -1) * PMA_pow(1024, 1);
    }
    return $return_value;
}
开发者ID:AmberWish,项目名称:laba_web,代码行数:19,代码来源:common.lib.php

示例4: PMA_formatNumber

/**
 * Formats $value to the given length and appends SI prefixes
 * $comma is not substracted from the length
 * with a $length of 0 no truncation occurs, number is only formated
 * to the current locale
 *
 * examples:
 * <code>
 * echo PMA_formatNumber(123456789, 6);     // 123,457 k
 * echo PMA_formatNumber(-123456789, 4, 2); //    -123.46 M
 * echo PMA_formatNumber(-0.003, 6);        //      -3 m
 * echo PMA_formatNumber(0.003, 3, 3);      //       0.003
 * echo PMA_formatNumber(0.00003, 3, 2);    //       0.03 m
 * echo PMA_formatNumber(0, 6);             //       0
 *
 * </code>
 * @param   double   $value     the value to format
 * @param   integer  $length    the max length
 * @param   integer  $comma     the number of decimals to retain
 * @param   boolean  $only_down do not reformat numbers below 1
 *
 * @return  string   the formatted value and its unit
 *
 * @access  public
 *
 * @author  staybyte, sebastian mendel
 * @version 1.1.0 - 2005-10-27
 */
function PMA_formatNumber($value, $length = 3, $comma = 0, $only_down = false)
{
    //number_format is not multibyte safe, str_replace is safe
    if ($length === 0) {
        return str_replace(array(',', '.'), array($GLOBALS['number_thousands_separator'], $GLOBALS['number_decimal_separator']), number_format($value, $comma));
    }
    // this units needs no translation, ISO
    $units = array(-8 => 'y', -7 => 'z', -6 => 'a', -5 => 'f', -4 => 'p', -3 => 'n', -2 => '&micro;', -1 => 'm', 0 => ' ', 1 => 'k', 2 => 'M', 3 => 'G', 4 => 'T', 5 => 'P', 6 => 'E', 7 => 'Z', 8 => 'Y');
    // we need at least 3 digits to be displayed
    if (3 > $length + $comma) {
        $length = 3 - $comma;
    }
    // check for negative value to retain sign
    if ($value < 0) {
        $sign = '-';
        $value = abs($value);
    } else {
        $sign = '';
    }
    $dh = PMA_pow(10, $comma);
    $li = PMA_pow(10, $length);
    $unit = $units[0];
    if ($value >= 1) {
        for ($d = 8; $d >= 0; $d--) {
            if (isset($units[$d]) && $value >= $li * PMA_pow(1000, $d - 1)) {
                $value = round($value / (PMA_pow(1000, $d) / $dh)) / $dh;
                $unit = $units[$d];
                break 1;
            }
            // end if
        }
        // end for
    } elseif (!$only_down && (double) $value !== 0.0) {
        for ($d = -8; $d <= 8; $d++) {
            // force using pow() because of the negative exponent
            if (isset($units[$d]) && $value <= $li * PMA_pow(1000, $d - 1, 'pow')) {
                $value = round($value / (PMA_pow(1000, $d, 'pow') / $dh)) / $dh;
                $unit = $units[$d];
                break 1;
            }
            // end if
        }
        // end for
    }
    // end if ($value >= 1) elseif (!$only_down && (float) $value !== 0.0)
    //number_format is not multibyte safe, str_replace is safe
    $value = str_replace(array(',', '.'), array($GLOBALS['number_thousands_separator'], $GLOBALS['number_decimal_separator']), number_format($value, $comma));
    return $sign . $value . ' ' . $unit;
}
开发者ID:kebyn,项目名称:apache_workspace,代码行数:77,代码来源:common.lib.php


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