当我执行while循环以获取数组中的结果时,json_encode()错误输出


json_encode() error output when i do an while loop to fetch the results in a array

从这个php中,同时循环i在数组中获取结果

$rows = array();
$result = mysqli_query($con,"call getProductVariationByID($name)");
//$row = mysqli_fetch_array($result);
 while ($row = mysqli_fetch_assoc($result))
   {
    $rows['Product'][] = $row;
   }
  echo json_encode($rows, JSON_PRETTY_PRINT);

结果是最后出现了这个"null":

        "post_mime_type": "",
        "comment_count": "0"
    }
  ]
}null

我敢打赌,包含此代码的函数在您的主php脚本中是echo'd。