我有:
if ( isset( $_POST["test"] ) ) {
$html1 = $object->htmlmarkup1();
$html2 = $object->htmlmarkup2();
$json = array("html1" => $html1, "html2" => $html2);
die(json_encode($json));
}
这些函数根据“测试”POST 数据的一些计算来回显 html 标记。这些函数使用 echo 而不是 return,因为我在其他地方使用这些函数,而且我的代码格式更容易回显函数的结果,而不是先返回结果。
我通过将“test1”和“test2”放在两个数组元素中并在我的测试页面中正确地解码并显示“test1”和“test2”,在不使用函数的情况下对此进行了测试。