-4

I want to display my PHP variable to JavaScript value Here is my PHP and javascript code.

<?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>

inside the text parameter i want to pass my PHP variable.

Haj Mohamed A
  • 83
  • 1
  • 8

2 Answers2

-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>
Guillaume
  • 586
  • 3
  • 21
-3

You can do it by using the following code

     <script>
          $('#typewriter').typewriter({
          prefix : "*** ",
          text : ["<?php echo $text;?>"],
          typeDelay : 50,
          waitingTime : 1500,
          blinkSpeed : 200
        });
     </script>
Zahid Iqbal
  • 112
  • 7