SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php and javascript

    I am not sure if this belongs here or in php

    I have an array of graphics, set in javascript.

    I want to modify the array, based on variables I set in php.

    Can I know the values of the php variables in the javascript?

  2. #2
    grasshoppa Snowbird122's Avatar
    Join Date
    Apr 2001
    Location
    Austin
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, javascript and PHP cannot share variables because PHP is executed on the server side and javascript is executed on the client side. This means that PHP is always executed before javascript.

    As long as you know this, you can use it to your advantage. You can use PHP to write javascript.

    For example:

    Code:
    <script language="javascript">
       alert ('Welcome to the site <?php echo $name; ?>');
    </script>
    http://www.echo-consulting.net - Sound Solutions for Online Inspriations.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •