我有一個簡單的 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.
如何使用 HTML 表單輸入使 json_decode 在 OOP 語句中工作
慕婉清6462132
2021-10-15 16:06:37