Typed the function fopen fopne accident
changed) this would generate an error, and we'd see our mistake immediately. But PHP is weakly-typed, so the string values are converted to integers for this addition. Since none of our strings begin with digits, each is assigned an integer value of zero, and so the value of $fullname is also zero. This mistake doesn't result in an error being raised at all by PHP, so could potentially be very hard to track down. If we display $fullname on screen and get a result of 0, it's fairly obvious what's happened. But if we simply write the result to a database, it could be a long time before we realize that an error has occurred at all.
Logical Errors
This code iterates through an array containing the names of various types of cat and deletes the element from the array if its value is "Manx". This produces the following output:
Because logical errors don't directly result in error messages being raised, it is possible – as in our example – for the entire code to execute without any apparent errors. This can make this sort of error extremely difficult to find. However, logical errors can be prevented by good program design. If we had followed through the logic of the loop above, we would have seen the error even before writing the code.
Environmental Errors
For example, if we typed the function fopen() as fopne() by accident, we would see an error message similar to this: