Cheap Web Hosting
Reviews and Articles
low cost high quality hosting
Cheap Web Hosting Reviews and Articles
Cheap Web Hosting        Web Hosting Reviews Articles FAQ Recommended Web Hosting
Options
Cheap Web Hosting Cheap Web Hosting
Cheap Web Hosting, Hosting Reviews Web Hosting Reviews
Cheap Web Hosting, Articles Articles
Cheap Web Hosting, Frequently Asked Questions Frequently Asked Questions
Cheap Web Hosting, Quality AvaHost WebHosting Recommended
Web Hosting
Cheap Web Hosting, Links Links


low cost web hosting Cheap Web Hosting
AvaHost.net










Inexpensive Web Hosting

Web Hosting Articles
Errors: examining the world of frustrations

As programmers and web designers, errors are inevitable. Often, time constraints that surround programming projects are concerned not with original code generation, but with code debugging, a large and resource intensive task within many computing jobs. Don't think of errors as problems, but as opportunities to improve your code to ensure correct functioning of your finished project. Part 1 of this article examines 4 types of errors on the Internet, how to recognize them and ultimately how to recover quickly from them. Part 2 takes a look at PHP-specific errors, what they mean and introduces PHP's support for custom error reporting.

The 4 types of Internet errors

Usually, errors on the Internet can be broken down into 4 categories. Let's take a look at each in stride and consider an example of each.
  1. Syntax errors

    These are mistypings or other errors in code that prevent the execution of a script. A syntax error is the only error type that prevents the script from any execution. Let's take a look at an example using PHP.

    -----Syntax Error-----
    $x = 1
    echo $x;

    The above is an error because every executable line within PHP must be terminated with a semicolon. The second line is correct, but the first line is not.

    Other syntax errors include unbalanced parenthesis within mathematical equations, mistyped language keywords and extra curly braces, among many others. Many times, syntax errors are the easiest to diagnose because error messages display the problem and also the problem's location.

  2. Semantic errors

    Semantic errors include technically correct code, but fundamental problems with the meaning of the code. Since compilers often do point to the error, semantic errors can be found and diagnosed in many cases without much heartache. The following example

    -----Semantic Error-----
    include("file.txt");

    would be a semantic error if file.txt did not exist, and therefore could not be included within the document. Please note that although, on the surface, semantic errors can closely resemble syntax errors, a script can be executed until the point of the semantic error, unlike scripts that include syntax errors. This is because semantic errors contain correct code, like our example above. It just so happens that file.txt does not exist, but the compiler has no way of knowing until it reaches that specific line of code.

  3. Logic errors

    The most difficult to diagnose, logical errors contain syntactically and semantically correct code, but does not execute the way the programmer has intended. This is often what drives programmers up a wall, especially with large and complex Internet applications.

    Logic errors can be as simple as wrong operator usage (+ instead of -, / instead of *) to as complex as database record calls and elaborate SQL statements. A logic error in PHP might look something like this:

    -----Logic Error-----
    $States = array ("Alabama", "Alaska", "Arizona",
    "Arkansas", "California");
    echo "The first record in the States array is " . $States[1];

    The 5 states listed in alphabetical order are saved to an array called States. The logic error comes in the 2nd statement, when we intend to output the first record in the array, or Alabama. Experienced programmers will pick this error up immediately, but to those without much knowledge in programming, it may seem cryptic. Simply put, array positions begin with 0, not 1. The 2nd statement will output Alaska, not Alabama like we intended to do. To fix this, we would simply modify the output to $States[0] instead of $States[1].

    Another logic error might be including the wrong file, adding wrong variables or simply forgetting to manipulate data. Compilers cannot find logic errors, as it has no knowledge of what the programmer intends to do. In the above snippet of PHP code, there is nothing wrong with outputting cell position 1 in the array, so the compiler did it without any problem. Therefore, logic errors must be determined and remedied only by the programmer.

  4. Environment errors

    Environment errors are often forgotten, but are very real within the Internet community. Environment errors are errors beyond the programmer's control, and can include absent language components within ASP to register_globals being turned off within PHP. It can be said, however, that environment errors occur least often out of the aforementioned 3 error types.





hosting features


Copyright (c) CheapWebHosting 2002