How can i add php content or php variable inside Java-script alert box?! I tried to make it work few ways but it is only popping up a blank box rather than the contents of p
Change this
alert (<?php $b ?>);
to this
alert ('<?php echo $b; ?>');
You need to output the value of $b
and add quotes inside the alert.
About PHP - echo
1.
<script>
alert("</script><?php $r=5;echo $r;?> <script>")
</script>
you have to script off on when php start
I use it like this
$text="Example PHP Variable Message";
echo '<script type="text/javascript">alert("'.$text.'")</script>';
Have you tried this?
alert ('<?php echo $b ?>');
This worked for me :
alert ("<?php echo $b; ?>");