[Sat Aug 12 02:21:28.993810 2017] [php7:notice] [pid 20352] [client :14302] PHP 注意:在/var/www/zephyr/library/XenForo/Application.php 中遇到格式不正确的数值在线 1534

    /**
 * Gets the current memory limit.
 *
 * @return int
 */
public static function getMemoryLimit()
{
    if (self::$_memoryLimit === null)
    {
        $curLimit = @ini_get('memory_limit');
        if ($curLimit === false)
        {
            // reading failed, so we have to treat it as unlimited - unlikely to be able to change anyway
            $curLimit = -1;
        }
        else
        {
            switch (substr($curLimit, -1))
            {
                case 'g':
                case 'G':
                    $curLimit *= 1024; //This is line 1534
                    // fall through

                case 'm':
                case 'M':
                    $curLimit *= 1024;
                    // fall through

                case 'k':
                case 'K':
                    $curLimit *= 1024;
            }
        }

        self::$_memoryLimit = intval($curLimit);
    }

    return self::$_memoryLimit;
}

不太确定如何解决这个问题,有点难住,我指出了第 1534 行

最佳答案

您将字符串与 $curLimit *= 1024; 中的整数相乘。因为 $curLimit 等于(例如) 512M 。所以你要做的是 删除最后一个字符 :

$curLimitNumber = substr($curLimit, 0, -1);//Will extract the number (512 FROM 512M)
switch (substr($curLimit, -1))
        {
            case 'g':
            case 'G':
                $curLimitNumber *= 1024;

关于PHP 通知 : A non well formed numeric value encountered in/var/www/zephyr/library/XenForo/Application. php on line 1534,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45648680/

10-10 21:44