[英]how to add a qr code image if the text code is more than 100
如果文本代碼$result['data']['checkout_url']超過 100,如何添加二維碼圖像
圖片源代碼
<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&choe=UTF-8&chl=<?= $result['data']['checkout_url']; ?>" width="200">
要編輯的代碼
if (filter_var($result['data']['checkout_url'], FILTER_VALIDATE_URL)) {
return redirect()->to($result['data']['checkout_url']);
} else {
$this->session->setFlashdata('success', 'Silahkan transfer sebesar Rp ' . number_format($data_post['quantity'],0,',','.') . ' ke ' . $result['data']['checkout_url'] . ' melalui ' . $data_method[0]['name'] . ' sebelum 1x24 jam.');
return redirect()->to(str_replace('index.php/', '', site_url(uri_string())));
}
} else {
$this->session->setFlashdata('error', $result['message']);
return redirect()->to(str_replace('index.php/', '', site_url(uri_string())));
}
}
$chl = isset($_GET['chl']) ? $_GET['chl'] : ''; //Get the value of chl from the img
if(!empty($chl)) // If its not empty
{
$chl_length = strlen($chl); //Get the length of the string - example 35
if($chl_length > 100) { //If the str length is longer the 100 chars
//DO this
}
else {
//Do something else
}
else {
echo "Error: chl is empty";
}
進一步了解PHP strlen
它實際上可以超過 100 個字符。
chl
查詢參數中設置原始 url 。 最好這樣做,使用urlencode()
function
<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&choe=UTF-8&chl=<?= urlencode($result['data']['checkout_url']); ?>" width="200">
掃描 qr 后,使用urldecode()
function 再次將其更改為 raw url,然后再進行下一步。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.