How to display a popup alert() in JavaScript when a PHP condition is true

3 Answers

0 votes
<?php $a = 3; if ($a === 3) { ?>
    <script type='text/javascript'>
        alert("ok");
    </script>
<?php } ?>

 



answered May 15, 2016 by avibootz
0 votes
<?php $a = 3; if ($a === 3) : ?>
    <script type='text/javascript'>
        alert("ok");
    </script>
<?php endif ?>

 



answered May 15, 2016 by avibootz
0 votes
$a = 3; 
if ($a === 3) 
{
    echo "<script type='text/javascript'>";
    echo 'alert("ok");';
    echo "</script>";
}

 



answered May 15, 2016 by avibootz

Related questions

...