我想提醒消息,但它不能与我的字符串一起工作。在JS警报中显示PHP变量
echo "<script>alert('$lang['ALERT']');
window.location.href ='index.php';
</script>";
不工作...帮助
我想提醒消息,但它不能与我的字符串一起工作。在JS警报中显示PHP变量
echo "<script>alert('$lang['ALERT']');
window.location.href ='index.php';
</script>";
不工作...帮助
你混的报价。保持简单,
echo "<script>alert('".$lang['ALERT']."');
window.location.href ='index.php';
</script>";
它的工作....赞赏Rikesh – ushtown
试试吧。
<script>
var alertMsg = "<?php echo $lang['ALERT'] ?>";
alert(alertMsg);
window.location.href ='index.php';
</script>;
它没有工作,感谢它作为rikesh – ushtown
你没有正确引用您的变量
<?php
$lang['ALERT'] = 'mystring';
echo "<script>alert('".$lang['ALERT']."');window.location.href ='index.php';</script>";
?>
试试这个
<script>
alert(<?=$lang['ALERT']; ?>);
window.location.href ='index.php';
</script>
报价是问题
<?php $alert=$lang['ALERT'];?>
<script>
alert('<?php echo $alert?>');
window.location.href ='index.php';
</script>;
你想要提醒什么? –
储存在$ lang中的字符串['ALERT'] – ushtown
请确保'$ lang ['ALERT']'是您所期望的。如果有什么**,它会发出警报吗? – ToothlessRebel