我試圖將用戶重定向到帶有 php 變數 $userdata 的 url 但是腳本似乎不起作用,它確實將它放在 html 中(用檢查元素確認)但它不會重定向。網址需要蜜蜂
$first = $user['first'];;
$second= $user['second'];;
$userdata = "'.$first.'&hello='.$second.'";
echo "<script> window.location = 'example/login?userid='.$userdata.'' </script>";
uj5u.com熱心網友回復:
用于json_encode()
將 PHP 字串轉換為格式正確的 JavaScript 字串。比使用 JavaScript 連接將其與<script>
.
$first = $user['first'];;
$second= $user['second'];;
$userdata = "$first&hello=$second";
echo "<script> window.location = 'example/login?userid=' " . json_encode($userdata) . ";</script>";
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/473835.html