You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenCart Aboss主题数值格式错误求助(PHP代码报错)

Fix for "Non well formed numeric value encountered" in OpenCart Aboss Theme's menu.php

Hey there, let's get this notice error sorted out for you. The issue is pretty straightforward: the variable $p being passed to the partition_element function isn't a valid numeric value (it might be a string, empty value, or non-numeric data), which causes problems with the division (/) and modulus (%) operations on lines 488 and 489.

Step-by-Step Fix

  1. Open the problematic file: Navigate to C:\xampp\htdocs\lojabootkamp\catalog\model\hozmegamenu\menu.php and locate the partition_element function.
  2. Add validation & type conversion for $p: At the very start of the function, add code to ensure $p is a valid positive integer. This fixes both the notice and potential division-by-zero errors.

Here's the updated function code:

function partition_element(Array $list, $p) {
    // Convert $p to integer and ensure it's a positive value
    $p = (int)$p;
    // Default to 1 if $p is 0 or negative to avoid division by zero
    if ($p <= 0) {
        $p = 1;
    }

    $listlen = count($list);
    $partlen = floor($listlen / $p);
    $partrem = $listlen % $p;
    $partition = array();
    $mark = 0;
    for($px = 0; $px < $p; $px ++) {
        $incr = ($px < $partrem) ? $partlen + 1 : $partlen;
        $partition[$px] = array_slice($list, $mark, $incr);
        $mark += $incr;
    }
    return $partition;
}

Why This Works

  • Casting $p to an integer with (int)$p converts any string that resembles a number (like "2") into a proper numeric type, eliminating the "non well formed numeric value" notice.
  • The check for $p <= 0 prevents fatal division-by-zero errors by defaulting to 1 when $p is invalid.

Save the changes, refresh your OpenCart site, and the notice should disappear.

内容的提问来源于stack exchange,提问作者Silvio Marques

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:43:54