How do I pass variables out of PHP and into html or javascript. I want to use this function to make an error message appear on the html form so the user knows which field she entered wrong. Thanks. ~Imozeb
This is how you can set a php variable as a javascript variable. <script type="text/javascript"> var test = <?php echo $phpVariable ?>; </script> HTML:
Alternatively, if you're the kind of person who prefers shorter solutions, rather than <?php echo $phpVariable; ?>, you can simply use <?=$phpVariable?>
Yeh I actually had that written but changed it because some people have short tags turned off Anyone that preferred a shorter solution probably wouldn't need to pass php variables into javascript anyway...