alert a php variable

PHP
echo '<script type="text/javascript">alert("'.$error.'");</script>';
Source

Also in PHP: