Specifications

Common causes of runtime errors include the following:
calls to functions that do not exist
reading or writing files
interaction with MySQL or other databases
connections to network services
failure to check input data
We will briefly discuss each.
Calls to Functions That Do Not Exist
It is easy to accidentally call functions that do not exist. The built- in functions are often inconsis-
tently named. Why does
strip_tags() have an underscore, whereas stripslashes() does not?
It is also easy to call one of your own functions that does not exist in the current script, but
might exist elsewhere. If your code contains a call to a nonexistent function, such as
nonexistent_function();
you will see an error message similar to this:
Fatal error: Call to undefined function: nonexistent_function()
in /home/book/public_html/chapter23/error.php on line 1
Similarly, if you call a function that exists, but call it with an incorrect number of parameters,
you will receive a warning.
The function strstr() requires two strings: a haystack to search and a needle to find. If
instead we call it like this:
strstr();
We will get the following warning:
Warning: Wrong parameter count for strstr() in
/home/book/public_html/chapter23/error.php on line 1
As PHP does not allow function overloading, this line will always be wrong, but we might not
necessarily always see this warning.
That same statement within the following script is equally wrong:
<?
if($var == 4)
{
strstr();
}
?>
Debugging
C
HAPTER 23
23
DEBUGGING
481
29 7842 CH23 3/6/01 3:41 PM Page 481