Passing value from PHP to JavaScript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uramesi39
    New Member
    • Jun 2012
    • 1

    #1

    Passing value from PHP to JavaScript

    i am new to php, can someone helpme

    This is php code
    Code:
    <?php
    
    $test1=100;
    $test2=200;
    $test3=300;
    
    ?>
    this is java script
    Code:
    <script type="text/javascript">
          function test() {
            var data = [  100,    1000,10000];
    </script>
    can i get value of $test1,$test2,$ test3 and replace value data with $test1,$test2,$ test3
    Last edited by Dormilich; Jun 11 '12, 09:49 AM. Reason: Please use [CODE] [/CODE] tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Use a PHP block to echo the values of the variables.

    Comment

    Working...