我想将PHP变量显示为JavaScript值 这是我的PHP和javascript代码。
<?php
$text = "Rates are subject to change without prior notice";
?>
<script>
$('#typewriter').typewriter({
prefix : "*** ",
text : ["Rates are subject to change without prior notice"],
typeDelay : 50,
waitingTime : 1500,
blinkSpeed : 200
});
</script>
在text参数中我想传递我的PHP变量。
答案 0 :(得分:-3)
<?php
$text = "Rates are subject to change without prior notice";
?>
<script>
$('#typewriter').typewriter({
prefix : "*** ",
text : [<?php echo $text; ?>],
typeDelay : 50,
waitingTime : 1500,
blinkSpeed : 200
});
</script>
答案 1 :(得分:-3)
您可以使用以下代码
来完成此操作 <script>
$('#typewriter').typewriter({
prefix : "*** ",
text : ["<?php echo $text;?>"],
typeDelay : 50,
waitingTime : 1500,
blinkSpeed : 200
});
</script>