php tag is not working in javascript tag

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eishita
    New Member
    • Feb 2010
    • 2

    php tag is not working in javascript tag

    I'm trying to use php tag in a javascript function. But unfortunately its not working. I even used <?php but still not working. I checked php.ini file and there the short tag is already enabled.

    Any sort of suggestion will be appreciated.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    what does your code look like?

    Comment

    • johny10151981
      Top Contributor
      • Jan 2010
      • 1059

      #3
      What is that mean php tag in javascript function?
      If you are saying that you are trying to put Javascript variable using php in server site then there is several option is available...
      as example
      Code:
      <?php
        $data='My message';
      ?>
      <script language='javascript'> 
      var A='<?=$data?>';
      </script>
      second is
      Code:
      <?php
        $data='My message';
      ?>
      <script language='javascript'> 
      var A='<?php echo $data?>';
      </script>

      Comment

      Working...