Use JavaScript Alert Box for PHP Trouble Shooting

In many computer programming languages, I always use message box to trace the errors or doing trouble shooting. However PHP do not come with a message box function. It makes the trouble shooting not so convenience. Luckily I can embed JavaScript inside the PHP code to do that. The following is a simple example to trace a variable.


// Declare a variable
$user = 'Alex, Hello World';

echo "Tracing the variable";

// Trace the $user variable with an alert box
echo "
  <script language=\"javascript\">window.alert('The user variable is: $user')</script>


Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>