|
|
|
| Title : |
Alert in JavaScript and Trace in Flash Action script are two commands that I find very much useful for tracking and debugging errors in my scripts. Unfortunately, there is no such option in PHP. |
| Categories : |
PHP, Java Script, Debugging |
 Sumit Agarwal |
| Date : |
Oct 19th 2007 |
| Grade : |
4 of 5 (graded 3 times) |
| Viewed : |
10758 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by Sumit Agarwal |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
Even though a simple echo can do the work most of the time, printing the message can break the layout at times. And at such times, this code can come handy :
| <?php
function alert($msg)
{
$msg = addslashes($msg);
$msg = str_replace("\n", "\\n", $msg);
echo "<script language='javascript'><!--\n";
echo 'alert("' . $msg . '")';
echo "//--></script>\n\n";
}
?>
<html>
<head>
<title>My Test Script</title>
</head>
<body>
<?php
$a = 50;
$b = ($a = 0) ? 'Empty' : 'Not Empty';
alert($a);
alert($b);
alert("\"Test sentence having quotes.\"");
alert("Another test sentance spanning multiple lines.");
?>
</body>
</html> | | |
|
| Classic guest book made with PHP and Flash Categories : PHP, Flash, Java Script | | | Zephyr: AJAX Based Framework for PHP5 Developers Categories : PHP, AJAX, Frameworks, Java Script, Web Applications | | | Dynamic Loading of XML array data into ComboBox and Display XML data using PHP + DOM + Javascript. Categories : PHP, Java Script, DOM XML, XML, Arrays | | | A Complete table(ADD,EDIT,VIEW,DELETE) management System PHP,MYSQL, JAVASCRIPT Categories : PHP, MySQL, Java Script, Databases | | | PHP Calendar Categories : PHP, Calendar, Date Time, Java Script, CSS | | | Menu in sliding bar or tree style. Handles frames by using small amount of javascript. Handles external and internal pages. Allows custom code to replace a menu item. Categories : PHP Classes, PHP, Java Script, DHTML | | | A Simple sign up script with PHP and JavaScript validations. Categories : PHP, Java Script, MySQL, Databases | | | Protect your mailto: email addresses from bots Categories : PHP, Email, Java Script | | | Create HTML forms dynamicly using Javascript & PHP Categories : PHP, PHP Classes, Java Script | | | Newbie Notes #4 - Trapping dumb MySQL query errors Categories : PHP, Databases, MySQL, Debugging, Beginner Guides | | | Script to check values being submitted by POST or GET method from a form. This script may help diagnose what variables are being supplied by a browser to other php scripts. Categories : HTML, Variables, Debugging, PHP, HTTP | | | OverEasy - PHP generated JavaScript to do mouseovers on
your pages. Modify one file and one function does it all
for you! Categories : PHP, Java Script, HTML and PHP, MySQL | | | Array values from javascript to php Categories : PHP, Java Script, Arrays | | | Tree Menu Dynamic (+Static) with Loading in Progress.. Categories : PHP, Java Script, HTML and PHP | | | Display variables when a form is submitted using POST/GET Categories : PHP, Functions, Variables, Debugging | |
| |
| |
|