how to print php variable in alert box code example Example: alert a php variable echo '<script type="text/javascript">alert("'.$error.'");</script>';