mardi 26 mai 2015

Inline if/else statement of JavaScript in PHP [duplicate]

This question already has an answer here:

I have a file written in PHP. I would like to have inline if/else statements of JavaScript in PHP. Is it possible? An example is given below:

    <?php

     echo "<script type=\"text/javascript\">
             function myFunction(a, b) {
                      if(a>b)
                          return true;
                      else
                          return false;
                       }

              if(myFunction(3,2)) { "; 
                     $x = '/index';
              echo "} else { ";
                           $x = '/index2';
                     echo "}";
     echo "</script>";

     ?>

Aucun commentaire:

Enregistrer un commentaire