我有一个简单的 HTML 表单,使用 json_encode 将 PHP 变量(通过 value=)发送到文件,然后使用 json_decode 提取和回显结果。我正在努力获得正确的语法或方法来解码 Opencart 所需的对象环境中的 json_decode。当我使用下面的程序方法时,它工作正常。我尝试了各种语法更改,但它们返回错误,因此我认为语法不正确,或者我的方法无法通过这种方式完成。第一个代码是返回正确结果的程序方法。第二个代码是失败的 OOP 方法。- (假设语法错误。Code Working:- <form id="myForm" action="radio_result.php" method="post" enctype="multipart/form-data"> <input type="radio" name="service" value="<?php echo htmlentities(json_encode($service_onx));?>"> ONX//additional code excluded.radio_result.php // not all code shown <?php if(!empty($_POST['service'])) { $service = json_decode($_POST['service'], true); print_r($service);Code failing:- <form id="myForm" action="index.php?route=checkout/checkout" method="post" enctype="multipart/form-data"> <input type="radio" name="service" value="<?php echo htmlentities(json_encode($service_onx));?>"> ONX checkout.php // not all code shown $this->session->data['service'] = (isset($this->request- >post(json_decode(['service'])))) ? $this->request->post['service'] : "not_set"; $data['onx'] = $this->session->data['service'][0]; $data['eta'] = $this->session->data['service'][1];Error result:-Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in C:\wamp64\www\catalog\controller\checkout\checkout.php on line 101I would like to get the json_decode working in the Opencart framework checkout.php so that I can use the reult further.
- 2 回答
- 0 关注
- 183 浏览
添加回答
举报
0/150
提交
取消